Question

We have very slow connection and very small hard disk, How can I create 1 TB VHD for cloud drive on azure?

Was it helpful?

Solution

Do you need to upload an existing VHD or you just need a 1 TB Azure drive for your application in the cloud? If it is former, Rinat is probably right. Look at this blog post for how to write a console app: blogs.msdn.com/b/windowsazurestorage/archive/2010/04/11/using-windows-azure-page-blobs-and-how-to-efficiently-upload-and-download-page-blobs.aspx.

However if you just need 1 TB Azure drive for your application, you can just create one using your code running in the cloud. You can write code similar to what I have written below:

string pageBlobName = "testpageblob";// Guid.NewGuid().ToString();

string blobUri = string.Format("{0}/{1}", blobContainer.Uri.AbsoluteUri, 
    pageBlobName);

CloudDrive cloudDrive = new CloudDrive(new Uri(blobUri), csa.Credentials);

for (int i = 0; i < 30; i++)
{
    try
    {
        cloudDrive.Create(20);

        break;
    }
    catch (CloudDriveException ex)
    {

        if (!ex.Message.Equals("ERROR_UNSUPPORTED_OS") || i == 29)
            throw;

        Thread.Sleep(10000);
    }
}


string driveLetter = cloudDrive.Mount(25, DriveMountOptions.Force);

OTHER TIPS

For efficient uploads you can write a simple console app that will upload your VHD to Azure Blob Storage as page blobs, transferring only non-zero bytes.

CSUpload does exactly that: uploads nonzero pages only.
You can create locally a (small) 1TB dynamic VHD and then upload with CSUpload (expanding to fixed size on-the-fly, without sending zero bytes). See also this question about having an 1TB disk in Azure.

you can also create a vm-disk and attach an vm to it and prepare it from there

then afterwards remove the disk from the vm(this will not remove it from storage) and mount it with cloudDrive

(you can delete the vm afterwards)

1TB is a extremely large size for vhd, however a brand new vhd only contain very little data(512 bytes for fixed hard disk image) at the end of file. In other words, the most data of your vhd is zero and there is no need to upload the entire 1TB data to azure storage.

For vhd file format, please refer to http://en.wikipedia.org/wiki/VHD_(file_format)

If you are familiar with vhd and azure storage client, you can write your own application to do these things.

  1. Create an empty 1TB page blob on azure storage with PutBlob operation

    http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx

  2. Write the VHD footer to end of the Page Blob with PutPage operation

    http://msdn.microsoft.com/en-us/library/windowsazure/ee691975.aspx

If not, you can use diskmgmt.msc(Disk Management) to create a vhd at first, and then use Set-AzureStorageBlobContent in windows azure powershell to efficiently upload your vhd. Set-AzureStorageBlobContent will skip the useless data when uploading page blob.

  Set-AzureStorageBlobContent -Container upload -File .\a.vhd -BlobType Page 

For reference, http://msdn.microsoft.com/en-us/library/dn408487.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top