Naming VHD blobs when creating a Virtual Machine Deployment

First of all make sure you are using the right Role.OSVirtualHardDisk.SourceImageName by getting the available images in powershell with the Get-AzureVMImage. I used the following method, which of course can be created better, but you get to the point (it’s working)…

private static Uri GetVhdUri(string blobcontainerAddress, string serviceName, string vmName, bool cacheDisk = false, bool https = false)
{
    var now = DateTime.UtcNow;
    string dateString = now.Year + "-" + now.Month + "-" + now.Day;

    var address = string.Format("http{0}://{1}/{2}-{3}{4}-{5}-650.vhd", https ? "s" : string.Empty, blobcontainerAddress, serviceName, vmName, cacheDisk ? "-CacheDisk" : string.Empty, dateString);
    return new Uri(address);
}

// Example call
string BlobContainer = "yourstorage.blob.core.windows.net/vhds";
GetVhdUri(BlobContainer, serviceName, vmName);
Advertisements

About Tamas Nemeth

Husband and proud father of two daughters in Nürnberg. I'm working as a Senior Software Developer and an enthusiastic Clean-Coder. I spend most of my free time with my family (playing, hiking, etc...). I also play table-tennis and badminton sometimes...
This entry was posted in Technical Interest and tagged , , , , , , . Bookmark the permalink.

One Response to Naming VHD blobs when creating a Virtual Machine Deployment

  1. Ray says:

    I feel that is among the so much important information
    for me. And i am happy studying your article. But want to statement on some common issues, The web site taste
    is great, the articles is actually excellent : D.
    Good activity, cheers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s