Follow-up Resources for PowerShell and Azure

I am teaching a class tomorrow how to do PowerShell and Azure to automate the creation of many VMs for computing results overnight. This is a reference page for them, but feel free to use what you can.

Setting up your template VM

First, you will want to set up a place to store the VM images that you are creating. Azure will assign you a location if you don’t do this step first, but it is not a very friendly name to remember later on. You will do this by creating a new storage location. This is found under the Data Services->Storage->Quick Create. The URL will be the friendly name of the storage location and the Replication only needs to be set to locally redundant for now.

image

Next, you will want a place to organize all of your running VMs. This is done in a Cloud Service. In the scripts later on, you will be able to specify the Cloud Service and then start, stop or delete all of the VMs in that service. This is key to making sure you aren’t billed for what you aren’t using.

image

It’s key here that the Region and Subscription match the storage location.

Now it’s time to create the VM you will be using as the base image later on. In class, we built a Windows Server 2012 Server. The wizard is pretty self explanatory, and I won’t spell it out here, but if you need more info, check out this video by Scott Hanselman. Once you connect to it, install any software that you want to customize the base image you are working on.

Next, you will need to prepare the VM for replication as an image by running Sysprep. This can be done by connecting to the VM and running “C:\windows\system32\sysprep\sysprep.exe” and choosing the out of the box experience and choose shutdown when the sysprep is complete.

image

Finally, in the Azure Management Portal, you can use “Capture” to change your current state VM into an image for future use. The scripts below will help this work.

Getting Started With Azure PowerShell

Download the Powershell Cmdlets for Azure here.

Configure Your Environment

Run the following Powershell CmdLet to download your publish settings file:

Now import it into your environment

 

Controlling VMs with PowerShell

I published the scripts for managing the VMs to github here: https://github.com/bsherwin/OSUResources