简体   繁体   中英

Check if azure VM compute Quota is available for a VM size via powershell

I am looking to see if there is a way to check my current azure quota based on input of a VM size? (NOT a VM family)

Sample input:

Standard_D1

Sample output:

Standard DDSv4 Family vCPUs: You have used X/Y available quota

The closest you can get to doing that is through the Usage - List API that @Jim mentioned above. The same is exposed via the Get-AzVMUsage PS cmdlet as well. Note that this cmdlet can only accept a Location parameter and not a VM Size as such.

Get-AzVMUsage -Location "West US 2"

However, if there is a hard requirement for you to fetch the quota for the size you provide, you could combine it with Get-AzComputeResourceSku as follows:

$Location = 'West US 2'
$VMSize = 'Standard_D4d_v4'

# Get the list of VM SKUs for the given location
$SKU = Get-AzComputeResourceSku -Location $Location | where ResourceType -eq "virtualMachines" | select Name,Family

# Figure out the VM Family for the provided size
$VMFamily = ($SKU | where Name -eq $VMSize | select -Property Family).Family

# Fetch the usage
$Usage = Get-AzVMUsage -Location $Location | Where-Object { $_.Name.Value -eq $VMFamily }

Write-Output "$($Usage.Name.LocalizedValue): You have consumed $($Usage.CurrentValue)/$($Usage.Limit) available quota"

# Sample Output
# Standard DDv4 Family vCPUs: You have consumed 16/100 available quota

Also take a look at this article for more information about vCPU quotas.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM