Microsoft

Preparing and uploading the base image for your Azure VM role

John Joyner outlines the steps involved in preparing your base image for the Windows Azure VM role and deploying it successfully.

In a previous article, I covered how to use the Azure Virtual Machine (VM) role and introduced the task of building the base VM image. The ability to upload your own VM image to the Azure public cloud, thereby making that image available consistently at Azure datacenters around the world, can be a unique business asset. Dozens or hundreds of instances of your VM role can rapidly be spun up and/or retired, in the appropriate geographic regions, as rapidly changing business conditions require. You need to upload your VM image before you can deploy Azure VM role instances from the image.

Azure VM deployment high-level steps

Following Microsoft's instructions to prepare your base VM image is important because your VM will become part of the Azure compute fabric, sharing virtual rack-space with Azure Worker and Web Roles. Microsoft supplies and services the OS image automatically (and out of sight) for web and worker roles. In the VM role, you supply and service the image.  To run inside the Azure environment, your VM image must be prepared in a manner that might be a little different from how you normally deploy Windows Server OS inside VMs.

From start to finish in your VM role deployment, there are about eight steps as follows. (In this article we are covering steps 1 to 6.)

  1. In Hyper-V Server, you create a new virtual machine and perform a default installation of Windows Server 2008 R2.
  2. After booting the virtual machine, you log in, install and configure the required OS features.
  3. Then install the Windows Azure VM Role Integration Components.
  4. Install additional software such as your application, services, or custom code.
  5. Apply the System Preparation Tool (sysprep.exe) to generalize the image and shut it down.
  6. Upload the Virtual Hard Drive (VHD file) to Windows Azure.
  7. Create a service model and configure it to use the deployed image using Microsoft Visual Studio.
  8. Generate a service package with Visual Studio, and deploy the package configuration files to your subscription using the Windows Azure Platform Management Portal.

Information needed to complete the base image OS installation

Use this information when you create the new virtual machine in Hyper-V that will become your base image:

  • When installing Windows Server 2008 R2 in the virtual machine, specify 2048-MB memory.
  • When configuring the virtual machine's network, specify a network with connectivity to the Internet. This network connection will be used by the virtual machine to access Windows Update.
  • Name the new virtual hard disk "baseimage.vhd".
  • Size the VHD to fit in the quota allocation for the VM role size purchased in your Azure subscription.

When you install the operating system (OS) (either Windows Server 2008 R2 Standard or Windows Server 2008 R2 Enterprise), take care to avoid creating a recovery partition during a default OS setup. A valid Azure VM image must allocate the entire virtual hard disk file to a single partition where you install the operating system. This might mean performing a custom setup of Windows (using <Shift + F10> to open a command prompt during GUI-mode setup), running diskpart.exe to create a single primary partition, and then proceeding with setup and installing into that partition.

Prepare Windows for the Azure VM Role

After the Windows OS installation is complete, and before you install your application or custom code in the VM image, there is some necessary configuration inside the VM.

1. Install .NET Framework 3.5.1 using the Add Features Wizard in Server Manager.

2. Microsoft recommends setting Windows Update not to automatically install updates in the Azure VM role base image.  In other words, use the "Never check for updates (not recommended)" setting.

3. After disabling automatic updating, proceed to update the VM by checking for updates at Windows Update and installing all recommended updates.

4.  Restart the VM, and repeat the check for updates, until all available and desired updates are installed.

5. Copy the wavmroleic.iso file from another computer where you installed the Windows Azure SDK (Software Development Kit) to the Hyper-V server's hard disk. Present the ISO image as virtual media (DVD drive) to the VM. 6. Inside the VM, run the WaIntegrationComponents-x64.msi installer file found on the ISO, this launches the Windows Azure VM Role Integration Components Setup Wizard, seen in Figure A.
Figure A - Installing the Windows Azure VM Role Integration Components
7. Enter an Administrator password for the VM during the Azure Integration Components setup. This password will persist after the image is prepared using the sysprep.exe System Preparation Tool.

8. The VM is now ready for final installation of your custom code or application software.

Run Sysprep.exe and upload the image to Windows Azure

After installation of your application software and a final check-out, it's time to "sysprep" the image with the System Preparation Tool. Run the tool with this command line inside the VM:

%windir%\system32\sysprep\sysprep.exe -generalize -oobe -shutdown

Next you might find it convenient to copy the baseimage.vhd file of the shut-down VM to the hard drive of your Azure administration workstation where the Windows Azure SDK and Visual Studio are installed. The tools to upload the image are located on the Azure administration workstation. To upload the image follow these steps:

  1. Open a Windows Azure SDK Command Prompt as an administrator from Start | All Programs | Windows Azure SDK v1.x.
  2. At the command prompt, execute csupload.exe Add-VMImage with the following example command line:

    cspload Add-VMImage -Connection "SubscriptionId=<YOUR-SUBSCRIPTION-ID>; CertificateThumbprint=<YOUR-CERTIFICATE-THUMBPRINT>" -Description "Base image Windows Server 2008 R2" -LiteralPath "<PATH-TO-VHD-FILE>" -Name baseimage.vhd -Location <HOSTED-SERVICE-LOCATION*>

    *Windows Azure data center location where the hosted service will be deployed (choose, "East Asia", "North Central US", "North Europe", "South Central US", "Southeast Asia", "West Europe")
  3. Initially, the tool executes a preparation phase where it mounts the VHD file and verifies it. It then processes the file to create a smaller compressed copy. You can watch the process of these phases and the actual upload phase in the same command prompt.
  4. When upload is complete and successful, verify the Committed status of the VM image in the online Azure management portal. Figure B shows the VM Images view in the portal with a verified baseimage.vhd uploaded.
Figure B - Confirming successful upload of the VM Image in the Azure customer portal

After a base image is uploaded, you can specify that particular base image for an Azure VM Role application that you will author in Visual Studio, as the next step to deploying the Azure VM role. In this example, baseimage.vhd will appear as a selectable base image in Visual Studio.

Also see:

About John Joyner

John Joyner, MCSE, CMSP, MVP Cloud and Datacenter Management, is senior architect at ClearPointe, a cloud provider of systems management services. He is co-author of the "System Center Operations Manager: Unleashed" book series from Sams Publishing, ...

Editor's Picks

Free Newsletters, In your Inbox