Please help me. I am writing following code to mount the vhd file. But I am not able to mount it. It works fine locally but when I deploy it on azure server the webrole remains offline. I tried by removing foreach block below but in vain. But when I removed the code "Global.driveLetter = drive.Mount(localCache.MaximumSizeInMegabytes - 20, DriveMountOptions.Force);" with foreach block, role got ready on server. But I can't do this because this is the key statement to mount the drive.
I am uploading my VHD using "Cloud Storage Studio".
What would be the problem?
private static void MountAzureDrive()Thanks in advance.
string connectionStringSettingName = "AzureConnectionString";
string azureDriveContainerName = "azuredrives";
string azureDrivePageBlobName = Guid.NewGuid().ToString("N").ToLowerInvariant();
string azureDriveCacheDirName = Path.Combine(Environment.CurrentDirectory, "cache");
CloudStorageAccount.SetConfigurationSettingPublisher((a, b) =>
CloudDrive.InitializeCache(localCache.RootPath + "cache", localCache.MaximumSizeInMegabytes);
// Just checking: make sure the container exists
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Create cloud drive
WebRole.drive = storageAccount.CreateCloudDrive("drives/Test.VHD");
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);
//Global.driveLetter = drive.Mount(25, DriveMountOptions.Force);
Global.driveLetter = drive.Mount(localCache.MaximumSizeInMegabytes - 20, DriveMountOptions.Force);
- Edited by BhimrajG Wednesday, April 04, 2012 7:21 AM Updated
According to your description, you have mounted the Drive in local, do you ever umount it before running on the cloud? As far as i know, every drive can only mount once (Access write), so please make sure it was unmounted before running.
Hope it can help you.
I have written code in onstop event to unmount the drive. Also for local I am using
For server I am using the code
So there will not be any problem which you mentioned in the post.
Yes, I am unmounting the VHD drive in onstop event of webrole
- Edited by BhimrajG Wednesday, April 04, 2012 10:00 AM updated