Using the new Quota REST API
Published Mar 04 2021 08:13 AM 24.7K Views
Microsoft

 

Devarayulu Tula, Senior Program Manager

Rahul Singh, Senior Software Engineer

 

Automation is a key aspect of DevOps and agile development. On January 19thwe announced the general availability of the Azure Quota REST API. The Quota API enables you to automate quota management and integrate it programmatically with your applications, tools, and existing systems. Now you can move your applications and systems faster to the cloud and free up your time to focus on your core business.

In this blog post, we give you an overview of the newly released Quota REST API and a step-by-step walkthrough with sample code that demonstrates how to use it when you reach a quota limit. For short, we will use Quota API throughout the rest of this blog.

What are quotas?

Quotas, also referred to as service limits, are the maximum values for the resources, actions, and items in an Azure account.

An Azure subscription is an agreement between a customer and Microsoft that enables the customer to obtain Azure services. The subscription pricing and related terms are governed by the offer chosen for the subscription. For a given subscription, region, and SKU there is a default quota. Each Azure service defines its quotas and default values. Here are some things to consider about quotas:

  • Just like credit cards have credit limits, Azure services have limits. A quota is the upper limit of consumption for an Azure resource.
  • A quota is shared across all the services in each subscription. When you are evaluating your capacity needs, you should calculate usage across all services.
  • Some services have adjustable limits. The limit can be raised above the default limit but not above the maximum limit. Default limits vary by offer category types, such as a free trial, pay-as-you-go, and virtual machine (VM) series (such as Dv4, Fsv2, and Easv4). See Azure subscription and service limits, quotas, and constraints for details about default and maximum limits.

Why Quota API?

To compete effectively, enterprises need to create an environment where developers can do their best work and operation teams can confidently meet the reliability, security, and compliance requirements their organizations expect. This requires advanced cloud capabilities designed to support modern constructs like containers, DevOps, APIs, and managed services—and the fluidity to work across environments and teams. Quota API can address this need for quota management automation and enabling quota management integration with your existing tools and applications. For details about the business benefits of using the Quota API, check out our blog post on the Microsoft Azure blog.

Using Quota API

Azure Quota API is a one-stop-shop for automating the process of viewing and managing quotas and eliminating the manual process of creating and managing quotas through support tickets in the Azure portal. Azure Quota API makes it easy to look up current quota usage and to request increases. With the current version of the Quota API, you can manage the service limits (quota) of Azure Virtual Machines (cores/vCPU) and Azure Machine Learning. In future releases, you will be able to take advantage of this capability to query current usage and quotas for additional Azure services and resources.

Azure Quota Management AutomationAzure Quota Management Automation



Usage scenario

This usage scenario illustrates how to use the Quota API to automate quota management to improve agility, developer velocity, and efficiency in IT operations.

Anna is a lead developer in the Contoso Cloud Readiness team. Contoso is an A/B testing company that tests firmware to be approved for cloud hardware. While testing, Anna needs to create many virtual machines (VMs) to test the firmware at scale. One of the challenges Anna faces is the inability to deploy new VMs because the maximum quota limit has been reached. This happens frequently and unexpectedly because of the inorganic growth in the usage of VMs in her organization. To continue with her workflow, Anna creates a support ticket manually to request a quota increase. But now, to improve efficiency in her workflow, she uses the Azure Quota API to automate quota request and validation operations end-to-end. She can check usage and monitor when her VMs reach the quota limit and automatically submit quota requests to increase limits. Anna's manual quota request process is now completely automated. This has helped her operations tremendously by paving the way for uninterrupted firmware testing.

When to request a quota increase

With the Quota API, you can find out what your current quota limit and usage values are and compare them with your quota needs. To determine when to request a quota increase follow this workflow:

  1. Determine how much quota is remaining:
    remaining quota = quota limit - current usage
  1. Request a quota increase when the remaining quota is less than the quota you need. If the remaining quota is greater than the quota you need, you don't need to request a quota increase.

Requesting a quota increase

Here's an example that illustrates how to determine if a quota increase is necessary and how to request it.

Anna is planning to deploy a new service in the East US region (eastus). She needs 20 general-purpose VMs for test and development that offer a balanced combination of vCPU(s), memory, and local disk. She picked 20 D3 v2 VMs (standardD3V2Family) which will support most of her production workloads. She also needs 5 NDs-series VMs (standardNDSFamily) to support parallel computing and machine learning workloads.

After initial deployment, Anna follows these steps to check the current usage of her NDs-series VMs and determine if she needs to request a quota increase for the NDs-series SKU in the East US region.

  1. Anna checks the remaining quota limit using the Quota API GET operation. Anna makes this GET request:
    GET https://management.azure.com/subscriptions/00000000-0000/providers/Microsoft.Capacity/resourceProviders/Microsoft.Compute/locations/eastus/serviceLimits/standardNDSFamily?api-version=2020-10-25​
    and gets this response:
    {
      "properties": {
        "limit": 10, // Quota limit
        "unit": "Count",
        "currentValue": 5, // Current usage
        "name": {
          "value": "standardNDSFamily",
          "localizedValue": "Standard NDS Family vCPUs"
        }
      }
    }
  2. From the GET response, she determines how much quota is remaining for this VM:
    remaining quota = quota limit - current usage = 10 - 5 = 5
  3. She needs a quota of 10 for VM so she needs to request a quota increase of 5. So, her new quota limit is:
    new quota limit = old quota limit + quota increase = 10 + 5 = 15
  4. Anna uses the Quota API PUT operation to request a quota increase of 5 with this PUT request:
    PUT https://management.azure.com/subscriptions/00000000-0000/providers/Microsoft.Capacity/resourceProviders/Microsoft.Compute/locations/eastus/serviceLimits/standardNDSFamily?api-version=2020-10-25​

    and request body:

    { 
     "properties": { 
     "limit": 15, // New limit 
     "unit": "Count", 
     "name": { 
       "value": "standardNDSFamily" 
     } 
     } 
    }   

 

If there is a quota failure

If you get a quota failure after you request an increase, try a smaller number rather than trying again with a bigger number. Using a bigger number might continue to cause failures. If you continue to get quota failures, follow the guidance on the How to create a support ticket via the Azure portal or use the Azure Support Ticket REST API to create it programmatically.

Share your feedback with us

Share your feedback or issues about the Quota API with us on Stack Overflow or GitHub.

Stack Overflow

To ask a question about the Quota REST API on Stack Overflow, go to the Stack Overflow home page and click Ask Question on the top right corner of the page. Enter a title and description for your question. Under Tags, enter at least one of these tags: quota, quota-api, or azure-quotas. For tips on preparing a question, go to How do I ask a good question?

GitHub

To report an issue with the Quota REST API on GitHub, click Issues at the top of the page for the language or interface you’re using. For example, if you are using the Microsoft Azure SDK for .NET, go to the  SDK for .NET GitHub repository, click IssuesNew issue. Choose your issue type (Bug report, Feature request, Question/Query template, or Report a security vulnerability) and click Get started. If none of these options matches your issue, click Open a blank issue at the bottom left of the page.

Learn more

Check out our Quota API product documentation for technical details on the Quota API REST operations that are currently supported, how to look up quota usage, request a quota increase, and deal with quota failures. Visit our post on the Microsoft Azure blog for the business benefits of using the Quota API.

 

Co-Authors
Version history
Last update:
‎Mar 04 2021 08:56 PM
Updated by: