質問

「Azure Webアプリケーション」を開発しています。

次のように、WebroleのDrive and DrivePathの静的メンバーを作成しました。

public static CloudDrive drive = null;
public static string drivePath = "";

次のように、Webrole.OnStartで開発ストレージドライブを作成しました。

LocalResource azureDriveCache = RoleEnvironment.GetLocalResource("cache");
        CloudDrive.InitializeCache(azureDriveCache.RootPath, azureDriveCache.MaximumSizeInMegabytes);

        CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
        {
            // for a console app, reading from App.config
            //configSetter(ConfigurationManager.AppSettings[configName]);
            // OR, if running in the Windows Azure environment
            configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));
        });

CloudStorageAccount account = CloudStorageAccount.DevelopmentStorageAccount;
            CloudBlobClient blobClient = account.CreateCloudBlobClient();
            blobClient.GetContainerReference("drives").CreateIfNotExist();
            drive = account.CreateCloudDrive(
                blobClient
                .GetContainerReference("drives")
                .GetPageBlobReference("mysupercooldrive.vhd")
                .Uri.ToString()
            );
            try
            {
                drive.Create(64);
            }
            catch (CloudDriveException ex)
            {
                // handle exception here
                // exception is also thrown if all is well but the drive already exists
            }

string path = drive.Mount(azureDriveCache.MaximumSizeInMegabytes, DriveMountOptions.None);
            IDictionary<String, Uri> listDrives = Microsoft.WindowsAzure.StorageClient.CloudDrive.GetMountedDrives(); 
            drivePath = path;

実行スコープがwebrole.onstartに残るまでドライブは目に見えるようになり、アクセスしやすい。

構成または他のエラーがありませんか?

役に立ちましたか?

解決 2

解決策を見つけました:

開発マシンでは、リクエストはローカルホストの発生しました。これにより、システムがクラッシュするようになりました。 servicedefinition.csdefの「サイト」タグにコメントすると、問題が解決します。

他のヒント

DrivePathを使用することを期待している他のコードはどこにありますか? Webアプリケーションにありますか?

もしそうなら、あなたはSDK 1.3を使用していますか? SDK 1.3では、Webアプリケーションのデフォルトモードは、完全なIISで実行されることです。これは、RoleEntryPointコード(OnStartなど)から個別のアプリドメインで実行されるため、2つの間で静的変数を共有できません。これが問題である場合、この初期化コードをGlobal.asax.csのApplication_beginに移動することを検討する場合があります(Webアプリケーションのアプリドメインにあります)。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top