How to select right Azure VM Size w/PowerShell


Right sized VM is half of success if no more! In the Azure IaaS cloud there is no option to edit VM virtual hardware settings like vCPU, vMemory, vSocket/vCore, vGPU, etc. Instead you have to select VMSize – this is consolidated vHardware profile, something like VM Template.

There are many VMSize related info on the Web, but no programmatic way to get enough info to make decision on selecting well-becoming VMSize for your workload.


  • The Microsoft AzureRM PowerShell module supplies a Get-AzureRmVMSize cmdlet that gives you very basic info about VMSizes, available in the specified Location.
Get-AzureRmVMSize -Location northeurope


  • I decided to write my own Get-AzVmSize function. The function is a part of Azure Automation Az-Module. It utilizes the Microsoft’s Get-AzureRmVMSize cmdlet and adds some functionality to help you to select proper VMSize that is better suited for your requirements.

  • This code will give you all available VMSizes in all existing Locations. The list can be very-very long.

Get-AzureRmLocation | Get-AzVmSize | Out-GridView
  • The Locations list can be filtered out by specified region, for example all US located Azure Datacenters. The list still will be long enough.
(Get-AzureRmLocation).Where{$_.DisplayName -cmatch 'US'} | Get-AzVmSize
  • To help you to select a single Location there is subsidiary Select-AzLocation function.
Select-AzLocation | Get-AzVmSize
Select-AzLocation -Region US | Get-AzVmSize
Select-AzLocation Asia | Get-AzVmSize
  • The -Region parameter is positional and supports Intellisense.



  • The main parameter is -Profile. It specifies the workload for which a VMSize is optimized. All logic is written accordingly to this Microsoft’s document.
Select-AzLocation Asia | Get-AzVmSize –Profile GPU


  • In the above example we can see two Locations in the Asia region and only one of them Southeast Asia allows to deploy GPU capable VM (VMSizes targeted for heavy graphic rendering).
  • There are three additional parameters to exclude VMSizes that do not meet minimum virtual hardware requirements. A -Core – minimum required vCPU count, -MemoryGB – minimum required memory and -DataDisk – minimum supported data disk count.

Select-AzLocation Asia | Get-AzVmSize -Profile GPU -Core 12 -MemoryGB 128 –DataDisk 12


  • All parameters are independent and may be mixed in any combinations.
Select-AzLocation | Get-AzVmSize -Profile GPU -Core 12 -MemoryGB 128
Select-AzLocation | Get-AzVmSize -Profile GPU -Core 12 –DataDisk 12
Select-AzLocation | Get-AzVmSize -MemoryGB 128 –DataDisk 12
Select-AzLocation | Get-AzVmSize -Core 12


  • The function returns custom object of [AzVmSize] data type. By default, only necessary properties are returned.
Select-AzLocation | Get-AzVmSize | Get-Member


  • There is option to change the default output by Select-Object or Format-Table cmdlets.
Select-AzLocation Europe | Get-AzVmSize -Profile General -MemoryGB 256 | Select-Object * -exclude Type
Select-AzLocation Europe | Get-AzVmSize -Profile General | Format-Table -Property VMSize, Cores, MemoryGiB, *disk*, Family -AutoSize


  • For more details about the functions, please take a look at the content based help and examples.
Get-Alias –Module Az-Module
Get-Help Get-AzVmSize -Full
Get-Help Select-AzLocation -Examples
Get-Help Get-AzVmSize -Parameter Profile

You might also like

How to login to the Azure automatically
How to find orphaned VHD files in the Azure
Add a data disk to an Azure VM
Azure Automation – Increase Azure VM disks

One thought on “How to select right Azure VM Size w/PowerShell

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s