Janne Mattila

From programmer to programmer -- Programming just for the fun of it

Quota usage reporting with Azure Resource Graph

Posted on: January 15, 2025

You can find your Quota usage by opening Quotas > My quotas in the Azure portal:

It allows you to see if you’re approaching your quota limits and allows you to act before you hit the limit:

You can also create alerts for quotas.

However, if you have a large environment or if you would like to create a report about the quota usage then Azure Resource Graph would be a better option.

Here is an example query that you can use to get the quota usage (based on the above article):

QuotaResources 
| where type =~ 'microsoft.compute/locations/usages' 
| where isnotempty(properties) 
| mv-expand propertyJson = properties.value 
| extend usage = propertyJson.currentValue, 
         quota = propertyJson.['limit'], 
         quotaLocalizedName = tostring(propertyJson.['name'].localizedValue),
         quotaName = tostring(propertyJson.['name'].value) 
| extend usagePercent = toint(usage) * 100 / toint(quota) 
| project-away properties
| where usagePercent > 80
| join kind=leftouter (ResourceContainers | where type=='microsoft.resources/subscriptions' | project subscriptionName=name, subscriptionId) on subscriptionId
| project subscriptionId, subscriptionName, location, usage, quota, quotaName, quotaLocalizedName, usagePercent

I want to highlight two important parts of the query:

1) mv-expand operator expands quota values into separate records.

2) Filtering the results to only show the resources that are using more than 80% of their quota:

| where usagePercent > 80

Here is an example output from the above query:

This can be exported to a CSV file directly from the view. Alternatively, you can Run queries with the Azure Resource Graph Power BI connector.

Of course, you can use Azure PowerShell and the Search-AzGraph cmdlet to get the same information and implement your own custom processing. See some examples about that in my repository e.g., find-subscriptions-without-policy.ps1, scan-private-endpoint-connections.ps1, or search for Search-AzGraph in the repository:

I hope you find this useful!