How to retrieve your subscription quotas using PowerShell
Overview
Quotas define the limit of the number of resources that a subscription can provision or consume.
The following process shows you how to retrieve the quotas for your subscription, as well as the current usage.
Prerequisites
Ensure your PowerShell environment is setup as detailed in Configure the Azure Stack Hub user's PowerShell environment.
Declare variables
Enter details below to provide values for the variables in the scripts in this article:
Variable name | Variable description | Input |
---|---|---|
$ArmEndpoint | The Azure Resource Manager endpoint for Azure Stack Hub |
Retrieving your quota
From your PowerShell window:
# Declare endpoint
$ArmEndpoint = ""
# Add environment
Add-AzEnvironment -Name "AzureStackUser" -ArmEndpoint $ArmEndpoint
# Login
Connect-AzAccount -EnvironmentName "AzureStackUser"
# Get location of Azure Stack Hub
$Location = (Get-AzLocation).Location
# Retrieve Compute quota
$ComputeQuota = Get-AzVMUsage -Location $Location | Select-Object -Property Name, CurrentValue, Limit
$ComputeQuota | ForEach-Object {
if (-not $_.Name.LocalizedValue) {
$_.Name = $_.Name.Value -creplace '(\B[A-Z])', ' $1'
}
else {
$_.Name = $_.Name.LocalizedValue
}
}
# Retrieve Storage quota
$StorageQuota = Get-AzStorageUsage | Select-Object -Property Name, CurrentValue, Limit
# Retrieve Network quota
$NetworkQuota = Get-AzNetworkUsage -Location $Location | Select-Object @{ Label="Name"; Expression={ $_.ResourceType } }, CurrentValue, Limit
# Combine quotas
$AllQuotas = $ComputeQuota + $StorageQuota + $NetworkQuota
# Export quota to CSV
$AllQuotas | Export-Csv -Path "AzureStackQuotas.csv" -NoTypeInformation
Feedback
If you find a problem with this article, click Improve this Doc to make the change yourself or raise an issue in GitHub. If you have an idea for how we could improve any of our services, send an email to feedback@ukcloud.com.