Monday, June 11, 2012

Reintroducing Windows Azure, Part 3: Virtual Machines

In this series we’re taking a fresh look at Windows Azure, which was re-launched on June 7 with a highly-publicized Meet Windows Azure event. In Part 1 we looked at the new portal and in Part2 the new Windows Azure Web Sites feature. Here in Parts 3 and 4 we’ll be looking at the new Virtual Machines feature—first from a Windows perspective (Part 3), and then from a Linux perspective (Part 4).

What are Virtual Machines for?

Historically, Windows Azure provided a Platform-as-a-Service (PaaS) capability which provided a high degree of management including automated patching. Along with this came a wealth of ever-expanding services that included core capabilities (compute, storage, relational database) as well as advanced capabilities (such as service bus and identity federation to name a few).
The PaaS offering had a lot going for it, but it wasn’t for everybody. As attractive as automated management is to a great many, some organizations simply prefer to do their own management. And as attractive as the capabilities of platform services are, they do often require you to design for cloud or make changes to existing applications. Finally, the non-persistence of PaaS VMs meant certain types of software couldn’t be run, such as server products that rely on local disk file storage. You couldn’t run products like SQL Server or SharePoint in this environment.
And so, PaaS fits the bill for many but not all. Some other cloud platforms have focused instead on Infrastructure-as-a-Service, which is the polar opposite of PaaS: You don’t have to learn something new, you don’t have to modify your applications, and you preserve portability—at the expense of having to do management yourself and denying yourself some of the advanced functionality PaaS services provide. Moreover, if the IaaS services provide persistent VMs (which they do on Windows Azure), it’s possible to run a wide variety of server products such as Active Directory, SharePoint Server, and SQL Server.
Windows Azure now has both PaaS and IaaS. The PaaS offering is called Cloud Services and the IaaS offering is Virtual Machines, our topic for today. Many people have gotten caught up in a debate between which is better, PaaS or IaaS. If I may, this is not a productive question to be asking: PaaS is the right choice for some purposes and organizations (but not all) while IaaS is more appropriate for others. Having both levels of cloud being supported strongly in the same platform is fantastic and is unique to Windows Azure. The table below contrasts Windows Azure’s PaaS and IaaS offerings.

Cloud Services
Virtual Machines
Platform-as-a-Service (PaaS)
Infrastructure-as-a-Service (IaaS)
Windows & SQL DB licensing included
Windows licensing included
Operating Systems
Windows Server 2008- 2012
Windows Server 2008-2012, Linux
Not persistent
Apps may need revision for cloud
Same VHDs run in-cloud or on-prem
Your responsibility
99.95% Compute (2 instances min)
99.9% (even for single instance)

Even though IaaS is viewed by some as a “lower” form of cloud in that you have to manage it yourself, the Windows Azure Platform makes it a pleasure to use, with a superb usability experience including the ability to compose VMs in the cloud.

Virtual Machines, Images, and Disks
There are 3 kinds of related artifacts to master when using the Virtual Machines feature: Virtual Machines, Images, and Disks. The portal’s area for Virtual Machines has a section for each. The illustration below shows the relationship between VMs, images, and disks:

Relationship Between Virtual Machines, Images, and Disks
A Virtual Machine is a VM instance you’re provisioned, based on an Image. That image can be a base operating system image (for example, plain vanilla Windows Server 2012) or a selection from the image gallery with a specific configuration (for example, Windows Server 2008 R2 configured with SQL Server 2012). The operating system disk (and optionally, data disks) are persisted as disks.

An Image is a configured and prepped operating system image that can be used to create VM instances. The image gallery includes stock offerings from Microsoft as well images you create yourself. You can create a VM by capturing the disk of a VM instance you’ve configured, or from some other VHD in your disks collection.

Disks are virtual hard drive (VHD files) backed by Windows Azure triple-redundant storage, and are portable between cloud and on-prem. When you create a new virtual machine, a VHD is created for it automatically. You have a collection of disks for your subscription. You can also upload VHDs from your local machine. VHDs are an underlying component of Virtual Machines and Images.

Creating a VM
We can create a VM by selecting CREATE A NEW VIRTUAL MACHINE in the Virtual Machines area of the portal, or by clicking + New at the bottom left. Select FROM GALLERY, and a list of images will be displayed that includes several flavors of Windows from Windows Server 2008 to Windows Server 2012 (aka Windows Server 8) as well as other operating systems. There are also choices pre-configured with server products such as SQL Server. We’ll choose Windows Server 2008 R2 in our example.

As we complete the wizard, we’re prompted to provide the following information:
·         A name and DNS name for our Virtual Machine (we’re going with “mynewvm” in our example)
·         An administrator password for remote connections
·         VM size
·         Region (the data center to provision in)

With the wizard complete, provisioning begins. You’ll initially see a Starting (provisioning) status.

When you see a status of Running, which will take a few minutes, provisioning is complete and the VM can be used.

Windows Azure Virtual Machines are persistent, meaning the disk is backed by triple-redundant storage, so we don’t have to worry about losing changes to local disk files.
Soon, we’ll be able to see the usage metrics of our VM in the portal. Metrics include CPU performance, data in/out, and disk read/write throughput.

Remote Connecting to a Windows VM
We can connect to our Windows Server VM using Remote Desktop. After clicking through to the detail page on the portal, there is a Connect action on the command bar. Clicking it opens an RDP file, which allows us to connect once we provide the correct admistrator password.

Soon we’re on the VM and can start setting it up the way we want in terms of software installation and configuration. In this case, we’ll configure Windows Server in the web server role so that IIS responds to web requests.

We’d need to add an HTTP endpoint in the portal in order to actually process web requests, but we’re not going to do that yet. Let’s say we want to set up a canonical VM from which we want to base an image, one that will allow us to make multiple instances of this configuration quickly and easily whenever we wish. In the next step we’ll capture the VM disk and make an image out of it.

Creating a Reusable Image from a Windows VM

After setting up a Windows VM the way we want it, we may want to use this configuration in the future without having to set it up manually again. We do this by creating an image. This involves four steps:
1.       Prep the VM for capture.
2.       SYSPREP and shut down the VM.
3.       Capture the VM’s disk.
4.       Create an image from the captured disk.

For Step 1, we connect to the VM and run SYSPREP (which you can find in Windows\System32\sysprep). We run SYSPREP, being sure to specify the option to generalize and selecting shutdown. This part of the operation is a bit manual and it’s important to follow the procedure exactly.

Proceed with the SYSPREP. You’ll lose the RDP connection which is normal.

Wait a bit, and when it finishes, you’ll see the VM shut down all by itself in the Windows Azure management portal and go to a status of Stopped.

With the VM stopped, we can capture its VHD using the portal’s CAPTURE command. We name our image (mynewimage) and confirm that we have sysprepped the VM.

With completion of the capture, our original VM is decommissioned but we now have an image named mynewimage listed in the Images section:

Now we can create instances from this image. Let’s create a new virtual machine from our gallery. Our newly created mynewimage image is listed in the gallery along with the default images from Microsoft:

We complete the wizard, and soon our VM instance is provisioned and started up. When its status goes to Running it is ready for use.

Let’s create a second instance of this VM, so that we can have a farm of servers working together as a unit. We repeat the same steps, creating another VM from the image we made earlier. This time, we indicate the second VM is to be associated with the first.

We also specify an availability set, so that these VMs are spread across fault domains in the data center. That ensures a major failure such as a power outage or a switch failure will not take out all copies of an instance.

Now we have created two VM instances from our image. Although the image pre-configures our instances for IIS, they won’t actually respond to Internet traffic until we create an endpoint, which we’ll do in the next step.

Adding an Endpoint
An endpoint will allow Internet traffic to be routed to one or several of your VMs with load balancing. Let’s set up an HTTP endpoint for the two VMs we created earlier. We select the detail page for the first of our linked VMs, and go to the ENDPOINTS section. The ADD ENDPOINT command adds an endpoint.

When provisioning completes, we have a new endpoint named http ready for use which we’ll be able to access at the production URL shown in the virtual machine’s detail page ( in our case) and the VMs will share the load.

Browsing to the endpoint shows us the default IIS page, confirming that communication to the VMs through the endpoint is working.


Windows Azure Virtual Machines provide an exciting IaaS counterpart to the platform’s traditional PaaS offering. It’s important to have both in a comprehensive cloud platform. The new portal and ability to do in-cloud VM composition make this feature very accessible. In this post we showed what the experience is like for Windows operating systems, and in Part 4 we’ll do the same for Linux.


Thorbjørn Sigberg said...

Great post, and good to get confirmed that the VMs are now persistent. It seems like a lot of the "official" information about the VMs are from back in 2011 and still states that online changes to the VM images are NOT persistent if the server they are on fails.

David Pallmann said...

What you're encountering are references to VM Role, which (along with Web Role and Worker Role) are part of the PaaS Cloud Services part of Windows Azure. Before we had formal IaaS support, VM Role was sometime describe as a form of IaaS. These PaaS VMs are definitely not persistent and require you to use a storage or database service for your data. The newer IaaS Virtual Machines, on the other hand, are persistent.