1

私を助けてください。vhdファイルをマウントするために次のコードを書いています。しかし、私はそれをマウントすることができません。ローカルでは正常に動作しますが、Azure サーバーにデプロイすると、webrole はオフラインのままになります。以下の foreach ブロックを削除してみましたが、無駄でした。しかし、「Global.driveLetter = drive.Mount(localCache.MaximumSizeInMegabytes - 20, DriveMountOptions.Force);」というコードを削除すると、役割がサーバーで準備されました。しかし、これはドライブをマウントするための重要なステートメントであるため、これを行うことはできません。

問題は何でしょうか?

    private static void MountAzureDrive()
    {
        string connectionStringSettingName = "AzureConnectionString";
        string azureDriveContainerName = "azuredrives";
        string azureDrivePageBlobName = Guid.NewGuid().ToString("N").ToLowerInvariant();
        string azureDriveCacheDirName = Path.Combine(Environment.CurrentDirectory, "cache");

        CloudStorageAccount.SetConfigurationSettingPublisher((a, b) =>
        {
            b(RoleEnvironment.GetConfigurationSettingValue(connectionStringSettingName));
        });

        //CloudStorageAccount storageAccount=CloudStorageAccount.FromConfigurationSetting(connectionStringSettingName);
CloudStorageAccount storageAccount=CloudStorageAccount.DevelopmentStorageAccount;

        LocalResource localCache=RoleEnvironment.GetLocalResource("InstanceDriveCache");
        CloudDrive.InitializeCache(localCache.RootPath + "cache", localCache.MaximumSizeInMegabytes);

        // Just checking: make sure the container exists
        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
        blobClient.GetContainerReference("drives").CreateIfNotExist();

        // Create cloud drive
     //WebRole.drive=storageAccount.CreateCloudDrive(blobClient.GetContainerReference("drives").GetPageBlobReference("Test.VHD").Uri.ToString());
        WebRole.drive = storageAccount.CreateCloudDrive("drives/Test.VHD");

        try
        {
            WebRole.drive.CreateIfNotExist(512);
        }
        catch (CloudDriveException ex)
        {
            // handle exception here
            // exception is also thrown if all is well but the drive already exists
        }

        foreach (var d in CloudDrive.GetMountedDrives())
        {
            var mountedDrive = storageAccount.CreateCloudDrive(d.Value.PathAndQuery);
            mountedDrive.Unmount();
        }
        //Global.driveLetter = drive.Mount(25, DriveMountOptions.Force);
        Global.driveLetter = drive.Mount(localCache.MaximumSizeInMegabytes - 20, DriveMountOptions.Force);
    }

前もって感謝します。

4

1 に答える 1

1

当たり前のことかもしれませんが、Windows Azure にデプロイするときに、ストレージ アカウントを開発ストレージから変更しましたか? dev ストレージ エミュレーターがハードコードされています。

CloudStorageAccount storageAccount=CloudStorageAccount.DevelopmentStorageAccount;

于 2012-05-18T03:23:58.883 に答える