I somehow got into writing PowerShell script in the last few days for facilitating deploying Windows Azure VMs into configured subnets for our upcoming Windows Azure IaaS Training Days. (Here’s the shameless plug.)

First I got started with Windows Azure PowerShell cmdlet and set up Windows Azure PowerShell. Then… this world is never the same anymore. I … see the light. Anyway, so this allows me to run PowerShell within a Windows Azure subscription account. It’s almost like having Microsoft datacenters in my living room, I can stop by and check it out anytime. Just open up my PowerShell ISE and there you are, play as hard as you want. So I wrote some script and ended up what I am showing here.

I packaged a few cmdlets together into function calls such that I can deploy a VM, and add it into a load balancer, and an availability set by arranging the calls like the following:

image

So the above code will deploy the first VM, fe1, to a target service followed by deploying two more VMs, fe2 and fe3, and load balance the three and put the three into an availability set.

My bag packed, last night pre-flight…

And here’s an infrastructure I have set up in Windows Azure, this needs to be configured first, so employed Windows Azure DNS, an Affinity Group, storage account, and a virtual network with target subnets are all in place first. What I have set up are the following:

image

image

image

image

Then after about 2 consecutive sleepless nights and a lot of coffee, finally

Zero hour, 9 AM

Well actually it was 12:54 PM, I cleared my throat and said, “Ground control, this is Major Tom, over…” and here’s what happened:

image

… then lunch, email, more email… then about 20 minutes later, the job ended quietly

image

and examined the session history, here’s how it went:

image

image

image

image

and in my Windows Azure subscription, now there are eight VMs deployed into three subnets.

Ground Control, I’m back.

image

The three VMs deployed to the frontend subnet were load-balanced and placed in an availability set. Two SharePoint boxes were in an availability set and deployed to the midtier subnet. And the two VMs, dc1 and dc2 in an availability set, and a SQL Server 2012 were deployed to the backend subnet.

SNAGHTML122cfc2

And a number of data disks were also attached to intended VMs accordingly:

image

The virtual network now looked like this after the deployment:

image

On such a timeless flight

So never will I deploy a VM to Windows Azure without PowerShell again. The end.