Create alerts for quotas

You can create alerts for quotas and manage them.

Create an alert rule

Prerequisites

Users must have the necessary permissions to create alerts.

The managed identity must have the Reader role (or another role that includes read access) on the subscription.

Create alerts in the Azure portal

The simplest way to create a quota alert is to use the Azure portal. Follow these steps to create an alert rule for your quota.

  1. Sign in to the Azure portal and enter "quotas" in the search box, then select Quotas. In Quotas page, select My quotas and choose Compute Resource Provider. Once the page loads, select Quota Name to create a new alert rule.

    Screenshot showing how to select Quotas to navigate to create Alert rule screen.

  2. When the Create usage alert rule page appears, populate the fields with data as shown in the table. Make sure you have the permissions to create alerts.

    Screenshot showing create Alert rule screen with required fields.

    Fields Description
    Alert Rule Name Alert rule name must be distinct and can't be duplicated, even across different resource groups
    Alert me when the usage % reaches Adjust the slider to select your desired usage percentage for triggering alerts. For example, at the default 80%, you receive an alert when your quota reaches 80% capacity.
    Severity Select the severity of the alert when the rule’s condition is met.
    Frequency of evaluation Choose how often the alert rule should run, by selecting 5, 10, or 15 minutes. If the frequency is smaller than the aggregation granularity, frequency of evaluation results in sliding window evaluation.
    Resource Group Resource Group is a collection of resources that share the same lifecycles, permissions, and policies. Select a resource group similar to other quotas in your subscription, or create a new resource group.
    Log Analytics workspace A workspace within the subscription that is being monitored and is used as the scope for rule execution. Select from the dropdown or create a new workspace. If you create a new workspace, use it for all alerts in your subscription.
    Managed identity Select from the dropdown, or Create New. Managed Identity should have read permissions to the Subscription (to read Usage data from ARG) and Log Analytics workspace that is chosen(to read the log alerts).
    Notify me by There are three notifications methods and you can check one or all three check boxes, depending on your notification preference.
    Use an existing action group Check the box to use an existing action group. An action group invokes a defined set of notifications and actions when an alert is triggered. You can create Action Group to automatically Increase the Quota whenever possible.
    Dimensions Here are the options for selecting multiple Quotas and regions within a single alert rule. Adding dimensions is a cost-effective approach compared to creating a new alert for each quota or region.
    Estimated cost Estimated cost is automatically calculated cost associated with running this new alert rule against your quota. See Azure Monitor cost and usage for more information.

    Tip

    Within the same subscription, we advise using the same Resource group, Log Analytics workspace, and Managed identity values for all alert rules.

  3. After you've made your selections, select Create Alert. You'll see a confirmation if the rule was successfully created, or a message if any problems occurred.

Create alerts using API

Alerts can be created programmatically using the Monitoring API. This API can be used to create or update a log search rule.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}?api-version=2018-04-16

For a sample request body, see the API documentation

Create alerts using Azure Resource Graph query

You can use the Azure Monitor Alerts pane to create alerts using a query. Resource Graph Explorer lets you run and test queries before using them to create an alert. To learn more, see the Configure Azure alerts training module.

For quota alerts, make sure the Scope is your Log analytics workspace and the Signal type is the customer query log. Add a sample query for quota usages. Follow the remaining steps as described in the Create or edit an alert rule.

The following example shows a query that creates quota alerts.

arg("").QuotaResources 
| where subscriptionId =~ '<SubscriptionId>'
| where type =~ 'microsoft.compute/locations/usages'
| where isnotempty(properties)
| mv-expand propertyJson = properties.value limit 400
| extend
    usage = propertyJson.currentValue,
    quota = propertyJson.['limit'],
    quotaName = tostring(propertyJson.['name'].value)
| extend usagePercent = toint(usage)*100 / toint(quota)| project-away properties| where location in~ ('westus2')| where quotaName in~ ('cores')

Manage quota alerts

Once you've created your alert rule, you can view and edit the alerts.

View alert rules

Select Quotas > Alert rules to see all quota alert rules that have been created for a given subscription. You can edit, enable, or disable rules from this page.

Screenshot showing how the quota alert rule screen in the Azure portal.

View Fired Alerts

Select Quotas > Fired Alert Rules to see all the alerts that have been triggered for a given subscription. Select an alert to view its details, including the history of how many times it was triggered and the status of each occurrence.

Screenshot showing the Fired Alert screen in the Azure portal.

Edit, update, enable, or disable alerts

You can make changes from within an alert rule by expanding the options below the dots, then selecting an action.

Screenshot showing options for changing an alert rule in the Azure portal.

When you select Edit, you can add multiple quotas or locations for the same alert rule.

Screenshot showing how to add dimensions while editing a quota rule in the Azure portal.

You can also make changes by navigating to the Alert rules page, then select the specific alert rule you want to change.

Screenshot showing how to edit rules from the Alert rule screen in the Azure portal.

Respond to alerts

For created alerts, an action group can be established to automate quota increases. By using an existing action group, you can invoke the Quota API to automatically increase quotas wherever possible, eliminating the need for manual intervention.

You can use functions to call the Quota API and request for more quota. Use Test_SetQuota() code to write an Azure function to set the quota. For more information, see this example on GitHub.

Query using Resource Graph Explorer

Using Azure Resource Graph, alerts can be managed programatically. This allows you to query your alert instances and analyze your alerts to identify patterns and trends.

The QuotaResources table in Azure Resource Graph explorer provides usage and limit/quota data for a given resource, region, and/or subscription. You can also query usage and quota data across multiple subscriptions with Azure Resource Graph queries.

You must have at least the Reader role for the subscription to query this data using Resource Graph Explorer.

Sample queries

Query to view current usages, quota/limit, and usage percentage for a subscription, region, and VCM family:

QuotaResources
| where type =~ "microsoft.compute/locations/usages"
| where location =~ "northeurope" or location =~ "westeurope"
| where subscriptionId in~ ("<Subscription1>","<Subscription2>")   
| mv-expand json = properties.value limit 400 
| extend usagevCPUs = json.currentValue, QuotaLimit = json['limit'], quotaName = tostring(json['name'].localizedValue)
|where usagevCPUs > 0
|extend usagePercent = toint(usagevCPUs)*100 / toint(QuotaLimit)
|project subscriptionId,quotaName,usagevCPUs,QuotaLimit,usagePercent,location,json
| order by ['usagePercent'] desc

Query to summarize total vCPUs (On-demand, Low Priority/Spot) per subscription per region:

QuotaResources
| where type =~ "microsoft.compute/locations/usages"
| where subscriptionId in~ ("<Subscription1>","<Subscription2>") 
| mv-expand json = properties.value limit 400 
| extend usagevCPUs = json.currentValue, QuotaLimit = json['limit'], quotaName = tostring(json['name'].localizedValue)
|extend usagePercent = toint(usagevCPUs)*100 / toint(QuotaLimit)
|where quotaName =~ "Total Regional vCPUs" or quotaName =~ "Total Regional Low-priority vCPUs"
|project subscriptionId,quotaName,usagevCPUs,QuotaLimit,usagePercent,location,['json']
| order by ['usagePercent'] desc

Provide feedback

We encourage you to use the Feedback button on every Azure Quotas page to share your thoughts, questions, or concerns with our team.

Screenshot showing user can provide feedback.

If you encounter problems while creating alert rules for quotas, open a support request.

Next steps