Monitoring quotas programmatically

Published Jul 05 2021 10:14 PM 10.1K Views
Microsoft

Harish Bannai, Senior Azure Cloud Engineer

Jonathan Wang, Customer Engineer II

 

 

Some Azure services have adjustable quota limits. Monitoring these quota limits is critical for keeping mission-critical applications and services up and running. In this blog, we walk through the steps to use a custom script that monitors quotas for Azure services creates a support ticket leveraging the Azure Support REST API.

 

Step 1: Configure authentication for your app

 

Configure your app to use the Microsoft Identity Platform  (Azure AD) as the authentication provider. You can register the application using the Azure portal or Azure CLI.

 

Register your app with the Azure portal

 

  1. Follow these steps to register your app in the Azure portal.
  2. In Azure Active Directory click App registration, click on the application you’re registering to display its properties. You will see something like this:

pilara_0-1625517618667.png

 

  1. Make a note of the Object ID and Directory (tenant) ID values.

 

Register your app using Azure CLI

 

To register your app using Azure CLI, run the following command to obtain the Object ID and Directory (tenant) ID values:

 

get-azureadapplication -objectId

 

Step 2: Register the resource provider (RP)

 

Register the Azure resource provider (RP) for the service of the quotas you want to monitor. For example, if the RP is Microsoft.Compute, you register it as follows:

 

Register-AzResourceProvider -ProviderNamespace Microsoft.Compute

You will get this result:

 

 

ProviderNamespace : Microsoft.Compute
RegistrationState : Registered
ResourceTypes     : {availabilitySets, virtualMachines,
                    virtualMachines/extensions,
                    virtualMachineScaleSets…}
Locations         : {East US, East US 2, West US, Central US…}

 

 

Step 3: Monitor your quotas programmatically

 

Use this script to monitor and create a support case. Pass the values for  Subscription ID, Object ID, and Directory (tenant) ID obtained in the previous steps to the GetAzLimit.ps1 script to monitor quotas and auto-create the support case.

 

Co-Authors
Version history
Last update:
‎Jul 05 2021 10:14 PM
Updated by: