Wednesday, February 16, 2011

Creating the VM Role in an Azure Service

A VM Role is configured as a Role within a larger Hosted Service.  This is no different from a Web or Worker role except for the additional steps of creating and uploading the base VHD that the Role instances will be provisioned from.

The following example uses Visual Studio 2010 with the Azure SDK Installed to define and publish the service. It is important that the latest Azure SDK is installed, the VM Role capability is enabled, and Visual Studio is already configured to manage your subscription.

Create the VM Image
  1. Begin by creating a VM using Hyper-V

    1. The VHD size cannot exceed 15 Gb for an Extra Small VM, 30 GB for a Small VM, or 64 GB for a Medium to Extra Large VM.

    2. http://msdn.microsoft.com/en-us/library/gg465391.aspx

  2. Install Server 2008 R2

    1. Apply Windows Updates

    2. Add .Net Framework 3.5.1

  3. Install and configure your application(s)

    1. Be aware that the image will be prepared with sysprep. When provisioned, the VM will be unique and will complete mini setup.  Therefore the application must be in a state that is compatible with sysprep.  Any additional configuration that must be performed after mini-setup is complete should be scripted using a custom service, or defining Syncronous Commands in the unattend.xml created by step 4.

  4. Install the Azure VM Integration Components.

    1. http://msdn.microsoft.com/en-us/library/gg465409.aspx

    2. This generates an unattend.xml at the root of the system drive (with the Administrator password prompted for).  This unattend.xml is very specific to the VM successfully provisioning on Azure.  Sections can be added to the XML file, but not deleted.

  5. Install Azure Connect endpoint agent if it will be used.

  6. Apply any modifications to the unattend.xml to support installing or configuring your application.

    1. A combination of scripts or commands and the FirstLogonCommands and SynchronousCommand keys can be combined with the AutoLogon to orchestrate the actions.

  7. Run sysprep to generalize the image

    1. http://msdn.microsoft.com/en-us/library/gg465407.aspx

    2. sysprep /generalize /oobe /shutdown /unattend:"C:\unattend.xml"

Upload the VM (vhd) image
  1. Upload the VHD using the csupload tool that is included with the SDK.  This is accessed by launching the SDK Command prompt using "Run As Administrator".

    1. http://msdn.microsoft.com/en-us/library/gg465385.aspx

Author and Deploy an Azure Service
  1. http://msdn.microsoft.com/en-us/library/gg465379.aspx

    1. External endpoints are ports that are available publically in front of the load balancers and mapped to a particular role.

    2. Internal endpoints are available behind the load balancers and can be used to define specific endpoints (open TCP ports) for machine to machine communication. 

    3. Be aware that you cannot use FQDNs or DNS or the like – the intercommunication involves enumeration of role instances using Azure Service Runtime components combined with proper configuration using IP addresses.

    No comments: