Use PowerShell to Create Virtual Machine in Azure – Part 2

Doctor Scripto

Summary: Learn how to work with sizing names in Microsoft Azure.

Honorary Scripting Guy, Sean Kearney, is back again to show more really cool stuff in Microsoft Azure. Be sure to also read Use PowerShell to Create Virtual Machine in Azure – Part 1.

When you're creating a virtual machine, you need to specify its size. In Hyper-V or other virtualization solutions, you would normally specify parameters such as:

  • CPU count
  • Memory size
  • Primary disk size

In Microsoft Azure, when you're creating a virtual machine, you actually have a series of prepackaged configurations. These are accessed with the Get-AzureRoleSize cmdlet.

If you'd like to get this list sorted from the smallest available configuration to the largest, you can sort in the following manner:

Get-AzureRoleSize | sort-object MemoryinMb,Cores | Format-Table

If you prefer to have a nice readable list by the name assigned, use this:

Get-AzureRoleSize | Sort-object InstanceSize | format-table

If you're trying to get the A0 role size for your virtual machine, you can simply ask for the information in this manner:

Get-AzureRoleSize | Where { $_.InstanceSize –match 'A0' }

Here is the output from the command:

Image of command output

The coolest part is that there is some information you don't see by default in the Azure portal—interesting details that point out the advantages to certain configurations over others.

As an example, there is a property called MaxDataDiskCount. This is the maximum number of VHDs you can attach to your Azure virtual machine. So if you wanted to identify which configurations would allow for the use of more than three VHDs (this is data disks beyond the operating system volume), you could filter on the MaxDataDiskCount property:

Get-AzureRoleSize | Where { $_.MaxDataDiskCount –ge 3 } | Format-Table

Here is the output:

Image of command output

We can see that there are other properties to filter on, including the number of cores or whether the role sizes are good for web or worker roles.

With this information, we can now proceed to the next step, which is actually creating the virtual machine…

     …which will happen tomorrow. Stay tuned for our next exciting episode on the Hey, Scripting Guy! Blog.

I invite you to follow The Scripting Guys on Twitter and Facebook. If you have any questions, send an email to The Scripting Guys at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, remember eat your cmdlets every day with a dash of creativity.

Sean Kearney, Windows PowerShell MVP and Honorary Scripting Guy

0 comments

Discussion is closed.

Feedback usabilla icon