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 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=https://management.core.windows.net"
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 "https://portalvhdabc123.blob.core.windows.net/VHDS/sys.vhd" -Label "2012 Sys Prepped" -LiteralPath "C:vmssys.vhd" -OS Windows
Create a self-signed certificate in IIS