Hello all,
In this post, I will show you how to find available VM sizes in Azure for your subscription and location.
Basically, if you deploy virtual machines using Azure portal, you will be able to see only available VM sizes and you cannot make a mistake. But, if you want to automate VMs deployment using PowerShell, Azure CLI or ARM template, you need to know what VM sizes are available for your subscription in specified region.
If you run PowerShell command Get-AzVMSize -Location <Location>, you will receive a long list of VM sizes. In general, these VM sizes are available in your Azure region, but not in your subscription as well. If you want to list available VM sizes for your subscription in Azure region, you need to run following command:
Get-AzComputeResourceSku | Where-Object {$_.Locations.Contains("northeurope")}
You will get output similar to this one (this output is a just short list :)):
ResourceType Name Location Zones Restriction Capability Value ------------ ---- -------- ----- ----------- ---------- ----- virtualMachines Standard_D1_v2 northeurope {1, 3, 2} MaxResourceVolumeMB 51200 virtualMachines Standard_D2_v2 northeurope {1, 3, 2} MaxResourceVolumeMB 102400 virtualMachines Standard_D3_v2 northeurope {1, 3, 2} MaxResourceVolumeMB 204800 virtualMachines Standard_D4_v2 northeurope {1, 3, 2} MaxResourceVolumeMB 409600 virtualMachines Standard_D5_v2 northeurope {1, 3, 2} MaxResourceVolumeMB 819200 virtualMachines Standard_D11_v2 northeurope {1, 3, 2} MaxResourceVolumeMB 102400 virtualMachines Standard_D12_v2 northeurope {1, 3, 2} MaxResourceVolumeMB 204800 virtualMachines Standard_D13_v2 northeurope {1, 3, 2} MaxResourceVolumeMB 409600 virtualMachines Standard_D14_v2 northeurope {1, 3, 2} MaxResourceVolumeMB 819200 virtualMachines Standard_D2_v2_Promo northeurope {1, 3, 2} NotAvailableForSubscription MaxResourceVolumeMB 102400 virtualMachines Standard_D3_v2_Promo northeurope {1, 3, 2} NotAvailableForSubscription MaxResourceVolumeMB 204800 virtualMachines Standard_D4_v2_Promo northeurope {1, 3, 2} NotAvailableForSubscription MaxResourceVolumeMB 409600 virtualMachines Standard_D5_v2_Promo northeurope {1, 3, 2} NotAvailableForSubscription MaxResourceVolumeMB 819200 virtualMachines Standard_D11_v2_Promo northeurope {1, 3, 2} NotAvailableForSubscription MaxResourceVolumeMB 102400 virtualMachines Standard_D12_v2_Promo northeurope {1, 3, 2} NotAvailableForSubscription MaxResourceVolumeMB 204800 virtualMachines Standard_D13_v2_Promo northeurope {1, 3, 2} NotAvailableForSubscription MaxResourceVolumeMB 409600 virtualMachines Standard_D14_v2_Promo northeurope {1, 3, 2} NotAvailableForSubscription MaxResourceVolumeMB 819200 virtualMachines Standard_F1 northeurope {1, 3, 2} MaxResourceVolumeMB 16384 virtualMachines Standard_F2 northeurope {1, 3, 2} MaxResourceVolumeMB 32768 virtualMachines Standard_F4 northeurope {1, 3, 2} MaxResourceVolumeMB 65536 virtualMachines Standard_F8 northeurope {1, 3, 2} MaxResourceVolumeMB 131072 virtualMachines Standard_F16 northeurope {1, 3, 2} MaxResourceVolumeMB 262144 virtualMachines Standard_A0 northeurope NotAvailableForSubscription MaxResourceVolumeMB 20480 virtualMachines Standard_A1 northeurope NotAvailableForSubscription MaxResourceVolumeMB 71680 virtualMachines Standard_A2 northeurope NotAvailableForSubscription MaxResourceVolumeMB 138240 virtualMachines Standard_A3 northeurope NotAvailableForSubscription MaxResourceVolumeMB 291840 virtualMachines Standard_A5 northeurope NotAvailableForSubscription MaxResourceVolumeMB 138240 virtualMachines Standard_A4 northeurope NotAvailableForSubscription MaxResourceVolumeMB 619520 virtualMachines Standard_A6 northeurope NotAvailableForSubscription MaxResourceVolumeMB 291840 virtualMachines Standard_A7 northeurope NotAvailableForSubscription MaxResourceVolumeMB 619520 virtualMachines Basic_A0 northeurope NotAvailableForSubscription MaxResourceVolumeMB 20480 virtualMachines Basic_A1 northeurope NotAvailableForSubscription MaxResourceVolumeMB 40960 virtualMachines Basic_A2 northeurope NotAvailableForSubscription MaxResourceVolumeMB 61440 virtualMachines Basic_A3 northeurope NotAvailableForSubscription MaxResourceVolumeMB 12288
In column Restriction, you can see that some of VM sizes have attribute NotAvailableForSubscription. If you check VM size, Standard_DS2_v2_Promo for example, you can see that size is not available for your subscription. But, if you check this VM size with first one PowerShell command, Get-AzVMSize -Location <Location>, you can see that VM size exist on that output also, but without any additional information.
Command that need to be used to list all available VM sizes for particular subscription is:
Get-AzComputeResourceSku | Where-Object {$_.Locations.Contains("northeurope") -and $_.Restrictions.ReasonCode -ne 'NotAvailableForSubscription'}
This looks a little bit tricky, but that is the way to find a proper VM size before you run your deployment scripts 🙂
Cheers,