December 11, 2010 at 3:25 PM
Apparently, I was lucky to be in the first batch of beta participants for the 3 new Azure beta programs:
- I received the confirmation for the extra small instances rather fast
- Wednesday evening, I received confirmation for the Azure Connect beta program. You can read my post on that here: Azure Connect: VPN as a Service, a quick introduction.
- And later that night, I received confirmation for the VM Role beta program.
This post will demonstrate how to upload a virtual hard disk to the Azure storage and how to configure it to run it as your own instance(s) in the cloud.
Creating the VHD
Microsoft Hyper-V on server, or VMWare workstation on laptop?
I was very happy with Windows Virtual PC. It was lightweight, free and pretty stable. It allowed us, developers, to use it on our laptops on the road, at our customers, in the office. But there is one important thing: Virtual PC does not support a 64-bit OS on a guest system. And that became a big problem with the introduction of Windows Server 2008 R2; that operating system is only available in 64-bit, which makes sense.
Because of this, we needed an alternative:
- Hyper-V: free, stable, Microsoft-product, but not running on Windows 7
- VMWare Workstation: not free, stable, non-Microsoft product, but running on Windows 7
So, I decided to use VMWare for the creation of my virtual machines for Azure.
To leverage the full capabilities of the VM Roles, it would be better to use Hyper-V though, since that allows the usage of differencing disks, which would be a big timesaver for incremental updates to a virtual machine image. But for now, I’ve used VMWare, since I didn’t have a physical Hyper-V server available.
Preparing the Virtual Machine
I took the following steps to create the Virtual machine.
- Created a virtual machine
- Installed Windows Server 2008 R2 Enterprise edition on it
- I enabled the Application Server and Web Role (and therefore also the .NET Framework 3.5.1 features)
- I installed all updates, but disabled the auto update feature.
Installing the Windows Azure Integration Components
- The Windows Azure Integration Components are a set of components that are needed to be able to communicate with the Windows Azure Fabric controller. They need to be installed on the virtual machine, prior to uploading the machine to the Azure storage.
- Load the iso file that is found in the Azure SDK (iso directory - wavmroleic.iso) as a DVD/IDE in your virtual machine
- Start the installer on the virtual machine, by double clicking WaIntegrationComponents-x64.msi
- Follow the installation screen (Next-next-finish)
Please make sure that the firewall windows service is enabled (see ‘Things to know’ at the end of this post)
Sysprepping the Virtual machine
There are some specificities with VM Roles that are different from a typical hosting/IaaS solution. I discussed some of these in my previous post: Hosting BizTalk Server on Azure VM Role. One of the important things to know is that the machine name of the Virtual Machine is changed and assigned at runtime by the Azure Fabric controller. This makes sense, since it is possible to configure multiple instances for a VM Role.
To make the virtual machine ready for these actions, the machine needs to be ‘sysprepped’. This is a typical action that is taken when creating a base image for a machine. It provides a different SID and name for the machine.
- Run the %windir%\system32\sysprep\sysprep.exe tool
- In the popup windows, select the “Enter System Out-of-Box experience (OOBE)” for the System Cleanup Action
- Make sure that Generalize is selected and select Shutdown in the Shutdown options.
[Only with VMWare] : Convert to VHD file
- This step is only needed when using VMWare.
- I used the tool VMDK to VHD Converter and that allowed me to convert my VMWare virtual disk to a VHD.
Uploading the Virtual Hard disk (VHD)
The VHD file now needs to be uploaded. For this, the Azure SDK 1.3 comes with a command-line tool: CSUPLOAD. Using this tool, we can upload the VHD to our Azure subscription.
- Open the Azure SDK Command prompt
- Type the following command to link the context to your current subscription:
csupload Set-Connection “SubscriptionId=[SubscriptionId];CertificateThumbprint=[tp]”
The subscription id can be found on the management portal in the property grid, when selecting a subscription.
The certificate thumbprint needs to be a private certificate that is installed on the local machine and that is linked to the management certificates on the Azure portal. On the Azure portal, you can easily copy the thumbprint from the property grid.
- Now the upload command needs to be done
csupload Add-VMImage –LiteralPath [localpathtovhd] –Location “West Europe” –Name [cloudname]
Passing in the localpath to the VHD is important. Next to that, the location (data center) needs to be defined where the page blob will be created. And optionally you can specify a friendly name that will be used on the Azure management portal.
- When this is done, a verification window pops up. This indicates that the image will be mounted to verify some settings (like Operating System, etc). This verification is important because it can prevent you from uploading a VHD of several GBs, and then finding out there is an incorrect configuration.
If the operating system you’re uploading the VHD from does not support mounting a VHD, you can use the parameter –SkipVerify of the CSUpload tool to skip this step.
- After the verification, the upload to the Azure data center starts and that seems to be a good moment to have a sleep (like I did), take a break, or do something else. The upload typically will take some hours and therefore, the csupload tool is recoverable from connection errors.
- As soon as the upload process starts, you can already look at the Azure portal and see the status of the VHD as pending. The VHD is created as a page blob.
- After the upload is completed, you can see the status of the VHD to committed on the Azure portal. When the connection breaks, it is possible to re-execute the command and the upload will resume where it stopped. (see ‘Things to know’)
Configure the Azure Role Service
Create Visual Studio Project
- In Visual Studio (after installing the Azure SDK 1.3 and the VMRole Beta unlocker), you can create a new Visual Studio Cloud project and add a VMRole to the Cloud project.
- On the property page of the VMRole project, you can specify the credentials and the VHD that is uploaded to the Azure platform.
- On the Configuration tab page, you can specify the number of instances and the size of the instances (notice that I can use the Extra small instance size here, part of the beta program)
- It is also required to open the endpoints when needed (like when IIS needs to be used, you’ll typically create an HTTP endpoint on port 80 or 443)
Publishing the project to Azure
- Now it is straightforward to publish this project to Azure, using Visual Studio, or by uploading it on the Azure management portal.
- After the upload is done, you can see on the management portal the process of the Virtual machine.
- The roles take the following statuses
- Waiting for host
- Setting up Windows for first use
- Starting Windows
- Starting Traffic
Things to know & troubleshooting
Don’t disable the Windows Firewall service
On my virtual machine (locally), I had disabled the Windows Firewall service. Because of that, the installation of the Windows Azure Integration Components failed with the following exception (copying it here for bing/google search):
Product: Windows Azure VM Role Integration Components -- Error 1720. There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action InstallScriptAction script error -2147023143, : Line 81, Column 5,
After I enabled the Windows firewall service again, things worked smooth again.
Resuming the upload
- Just before the upload finished, I received a timeout exception on the csupload command. So, I decided to find out if the resumability of the CSUpload tool works as announced.
- I re-executed the command the 1st time and I noticed the upload started again at 3,2%… Knowing that I’ve seen the upload pending at 98%, the last time I checked, I decided to retry it again. (ctrl+c to exit the command)
- The second time, the resume started at 87,3%. So I tried again.
- And, third time lucky!, now I immediately received a confirmation of the upload. And the management portal also reflected this well.
Don’t install the Windows Azure SDK on the Virtual Machine
It is not supported to install the Windows Azure SDK inside a VM intended for use with VM role. The Windows Azure SDK and the Integration Components are mutually exclusive.
No support for startup tasks
Unfortunately there seems to be no support to use Startup tasks in VMRoles. So startup tasks will have to be ‘embedded’ in the Virtual Machine startup process. This might change after the beta, off course.
Again, just as with the Azure Connect, I was very surprised by the simplicity of the process of getting things to work. Off course, it takes more time, because of the preparation and the upload, but besides that, things looks solid and stable.
Things that I hope to see soon:
- Base images on Azure that can be downloaded, so that only the differencing disks need to be uploaded. This would save a lot of time and bandwidth. (download is cheaper/faster than upload)
- Start up tasks.
Sam Vanhoutte, Codit