Azure Cross-Platform Automation
Step-by-Step: Create a Virtual Machine with Azure xPlat CLI
When you provision a Microsoft Azure Virtual Machine (VM), you need to provision it from a reference image. The Azure platform provides a gallery containing many images for both Windows and Linux operating systems. We'll use the Microsoft Azure Cross-Platform (xPlat) CLI Tool to search the gallery for images, and find one to use to build our Virtual Machine.
Okay, now we're just about ready to start building our virtual machine, but the first thing we need to do is find a virtual machine operating system image to provision our virtual machine from. So let's call the "azure" command, and as you can see we've got a "vm" sub-command that allows us to do VM related operations. Several of those operations allow us to explore the gallery of virtual machine images that's available in the Microsoft Azure platform.
So, the first command we're going to run is "azure vm image list publishers." And we're also going to specify an Azure region where we want to list the publishers from. So in this case we're deploying our virtual machine to the "WestUS" region so we're going to specify that region for the location param.
So, if we scroll up a little ways here, you'll see that we have Microsoft Windows Server as a VM image publisher. So if we go back to the "azure vm" command, you'll see that we have "list-offers" as our next command. So we're going to call "azure vm image list-offers," we're going to specify that location again which is "WestUS," and then we're going to specify the publisher which is "MicrosoftWindowsServer." Once we list the offers, the next thing we need to do is list the SKUs.
So now we call the "list-skus" subcommand, and we specify the location, the publisher and the offer. The offer name is Windows Server. After we get the SKU, we next need to get the image details. So the final command is actually just "azure vm image list, " and then we can specify the publisher, offer and SKU. So let's call "azure vm image list," specify the publisher which is Microsoft Windows Server. Then we'll specify the offer which is "WindowsServer." Then we'll specify the SKU, and the SKU we'll use for this example is Windows Server 2012 R2 Datacenter Edition, then finally the location which is "WestUS."
So this is going to give us the details for that particular image and all the different versions that are available. As you can see, we've got three different versions of the 2012 R2 Datacenter image available. We have a 2015 August, a 2015 September, and a 2015 October image available. So we're going to go ahead and use the October 2015 image for our virtual machine.
Trevor Sullivan is a Microsoft MVP for Windows PowerShell, and enjoys working with cloud and automation technologies. As a strong, vocal veteran of the Microsoft-centric IT field since 2004, Trevor has developed open source projects, provided significant amounts of product feedback, authored a large variety of training resources, and presented at IT functions including worldwide user groups and conferences.