I would like create quota increase request through cli is it possible.

Anonymous
2023-12-12T13:58:51.4066667+00:00

Hi,
I would like to increase quotas through Python sdk or through cli is it possible? I am using the below code to list the resources and their limit. I checked the page for api but there is not much information.

https://learn.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2023_07_01.operations.usageoperations?view=azure-python

from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.network import NetworkManagementClient
y = a.compute_client.usage.list(location)
for i in y:
    if i.name.value == 'standardDSv2Family':
        i.limit=20
        print(i.name.value,i.limit,i.current_value)
a.compute_client.usage.create(location, y)
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,039 questions
{count} votes

1 answer

Sort by: Most helpful
  1. deherman-MSFT 38,021 Reputation points Microsoft Employee Moderator
    2023-12-12T17:56:10.5333333+00:00

    @Anonymous

    Yes, it is possible to create a quota request through the CLI and Azure Python SDK.

    For Azure CLI you can use the az quota command which is an extension that gets installed when you run the command.

    az quota create --resource-name standardFSv2Family --scope /subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus --limit-object value=10 --resource-type dedicated
    

    For Azure Python SDK you can use azure-mgmt-quota This is some sample code that you might find useful:

    import os
    
    from azure.identity import DefaultAzureCredential
    from azure.mgmt.quota import AzureQuotaExtensionAPI
    from azure.mgmt.resource import ResourceManagementClient
    
    
    def main():
        subscription = os.getenv('AZURE_SUBSCRIPTION_ID')
        quota_client = AzureQuotaExtensionAPI(DefaultAzureCredential(), subscription)
        resource_client = ResourceManagementClient(DefaultAzureCredential(), subscription)
    
        GROUP_NAME = 'zbw_test'
    
        # Create resource group
        resource_client.resource_groups.create_or_update(
            GROUP_NAME,
            {"location": "eastus"}
        )
    
        result = quota_client.quota.begin_create_or_update(
            resource_name=GROUP_NAME,
            scope='/subscriptions/' + subscription + 'providers/Microsoft.Compute/location/eastus',
            create_quota_request={
                "properties": {
                    "limit": {
                        "limit_object_type": "1000"
                    },
                    "resourceType": "dedicated"
                }
            }
        ).result()
        print(result)
    
        # delete resource group
        resource_client.resource_groups.begin_delete(GROUP_NAME).result()
    
    
    if __name__ == '__main__':
        main()
    

    Hope this helps! Let me know if you have an questions.


    If you still have questions, please let us know in the "comments" and we would be happy to help you. Comment is the fastest way of notifying the experts.

    If the answer has been helpful, we appreciate hearing from you and would love to help others who may have the same question. Accepting answers helps increase visibility of this question for other members of the Microsoft Q&A community.

    Thank you for helping to improve Microsoft Q&A! User's image

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.