Lessons learned while uploading a VHD to Windows Azure

Recently, while attempting to upload a VHD to Windows Azure, I encountered a few perplexing road blocks. Because it took significant research as well as trial and error to determine a work around, I'm posting my findings so that others can avoid those roadblocks.

I set out to deploy a Windows Azure VM node in Windows HPC Server 2008 R2. I followed the Step-by-Step Guide in this TechNet article:

https://technet.microsoft.com/en-us/library/hh184325(WS.10).aspx 

Roadblock #1 - Could not import the VHD to HPC image store

Everything worked as expected until I got to Step 5 - Upload a VHD to Windows Azure. Before uploading the file to Azure, the HPC process requires that the image be imported into the HPC image repository. I started this process, but it never finished. There were no error messages - it just ran forever. My research revealed that the root cause of the problem was that there was not enough space on the HPC head node c: drive. Since HPC requires that all the images that it manages reside on the c: drive, if there is not enough space, there is no work around right now. 

So, I gave up trying to use the HPC tools for the upload and turned instead to the Azure command line utility, csupload. I found a link which describes How to Upload a VHD to Windows Azure using this utility:

https://msdn.microsoft.com/en-us/library/windowsazure/gg465385.aspx

I had already sucessfully configured the management certificate to enable HPC to provision Worker Roles on Azure by exporting the Default Microsoft HPC Azure Management certificate (which gets automatically added to the Trusted Root Certification Authorities store when the HPC Pack is installed) and adding it to my Azure subscription. Consequently, when I read the note on step 3 that states, "The certificate that you use must be installed in the certificate store", I assumed that it already was. 

Roadblock #2 - Error with certificate

But when I tried to run the Set-Connection command, I received this error message:

Cannot access the certificate specified in the connection string. Verify that the certificate is installed and accessible.
The syntax for the connection string 'SubscriptionId=abcdef01-2345-6789-abcd-ef0123456789;CertificateThumbprint=abcdef0123456789abcdef0123456789abcdef01'
is not valid.

This was very confusing since I had already used this combination of Subscription ID and Certificate in a node template to add Azure nodes to the HPC cluster with no problems. After much research, I discovered a discussion forum where it was explained that the certificate had to be in the User Account as well as the Computer Account. So, I opened up the MMC and added the Certificates snap-in, specified the Computer Account and navigated to the Trusted Root Certification Authorities store. I did a right-click on the Default Microsoft HPC Azure Management certificate and selected All Tasks, then Export. I saved the .cer file to the desktop. I then closed the MMC without saving the settings, and reopened it again. This time, when I added the Certificates snap-in, I specified My User Account. I imported the .cer file from the desktop to both the Personal and the Trusted Root Certification Authorities stores. I probably didn't need to do both, but I wanted to make sure I covered all the options. Then, I retried the Set-Connection command and it ran with no errors.

Roadblock #3 - Cut and Paste from web site resulted in errors

For each of the steps in the upload process, the web site has code snippets which can be copied to the clip board for pasting into the command shell. When I tried this on step 4, I received the following error message:

Too many arguments for command Add-VMImage expects 0 argument(s) found 6.
Found: '-LiteralPath', 'VMRole.vhd', '-Location', 'SouthCentral US', '-Name', 'VMrole.vhd'
Named parameter "-LiteralPath <string>" missing for command Add-VMImage.

This one was especially difficult to debug, because everything was specified exactly as it should have been. I tried several times to modify the command with fewer parameters to see what the different error messages would say. I finally decided to type in the command rather than paste it from the web site. That fixed the problem. The command worked and I was able to upload the VHD.

I hope these insights will help others to work around these roadblocks without killing as much time as I did.