One does not simply upload a VM to Azure

Meme created by my co-worker Clay More.  I would point you to his website/blog but he doesn’t have one.clip_image002

I love the above meme and it’s true.  Uploading a virtual machine (VM) to Azure is not as simple as one would think.  The information below basically explains how to upload a sysprepped VM template to Azure.  This template can be used to create future VMs.  I’m assuming you have basic knowledge in creating self-signed certificates, installing software, and a few other things. 

First before you do anything make note that Azure does not currently support the new VHDX format introduced in Microsoft Windows 2012.  This may change in the future but today just plan on using the VHD format.  If you already have a VM in the VHDX format you can convert it using Hyper-V Edit Disk.

Before you even attempt to upload a VM to Azure there are a bunch of steps you need to do first. 

If you have not uploaded a management certificate to Azure you need to do this first.  These certificates are used by the SDK tools, the Windows Azure Tools for Microsoft Visual Studio, and the Windows Azure Service Management REST API. These certificates are independent of any hosted service or deployment meaning if you want to manage Azure you need management certificates. 

There are various ways to generate a management certificate.  In my example I created a self-signed cert by using IIS.

Once you generate a self-signed cert in IIS it automatically puts it in Certificates (Local Computer)-Personal-Certificates.  Since you’ll be using the CSupload.exe command you need to get this cert in YOUR Current User-Personal-Certificates container in the certificates MMC.  I did it by going in Certificates (Local Computer)-Personal-Certificates, double clicking on the self-signed cert, clicking the Details tab, then clicking on copy to file.  It walks you through a wizard where you can save it without the private keys as a CER file.  From there you import that cert file to Certificates-Current User-Personal-Certificates container.

The next step would be to export that cert with the private keys to a PFX file. This will be the file that you upload to the Azure by using the portal page.

Once you upload your certificate copy the subscription identifier and thumbprint for the certificate you just uploaded. You can get that information from the portal page.

Now you can open the Windows Azure Command Prompt.

The first thing you need to do is to set the connection info. Below is the command I used (I changed a few letters and numbers so you don’t know my real subscription ID or Certificate Thumbprint).
csupload.exe set-connection "SubscriptionID=ABC-123;CertificateThumbprint=XYZ789;ServiceManagementEndpoint="

Now we’re ready to upload our sysprepped image. For the destination you have to visit the Azure portal and go into storage go get the URL of your blob storage. I used the command below changing blob URL so you don’t know what mine is. BE SURE TO CHANGE THE BLOB FROM HTTP TO HTTPS OR YOU WILL GET A WARNING.
csupload Add-PersistentVMImage -Destination "" -Label "2012 Sys Prepped" -LiteralPath "C:vmssys.vhd" -OS Windows

Depending on your upload bandwidth in a few minutes or hours (in my case) your image is in Azure!

Create a self-signed certificate in IIS

CSupload commands

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s