{"id":7034,"library":"azure-mgmt-quota","title":"Azure Quota Management Client Library","description":"The `azure-mgmt-quota` library is the Microsoft Azure Quota Management Client Library for Python. It provides programmatic access to manage Azure resource quotas, including retrieving current limits, checking usage, and requesting quota increases. The current version is 3.0.1, and it follows the Azure SDK release cadence, with frequent updates to align with Azure service changes.","status":"active","version":"3.0.1","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/quota/azure-mgmt-quota","tags":["azure","quota","management","sdk"],"install":[{"cmd":"pip install azure-mgmt-quota azure-identity","lang":"bash","label":"Install package and authentication library"}],"dependencies":[{"reason":"Required for Azure Active Directory token authentication with Azure SDK client libraries.","package":"azure-identity","optional":false}],"imports":[{"symbol":"QuotaMgmtClient","correct":"from azure.mgmt.quota import QuotaMgmtClient"},{"symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.quota import QuotaMgmtClient\n\n# Ensure these environment variables are set for DefaultAzureCredential to work:\n# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID\n\nsubscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', 'YOUR_SUBSCRIPTION_ID')\n\nif subscription_id == 'YOUR_SUBSCRIPTION_ID':\n    print(\"Please set the AZURE_SUBSCRIPTION_ID environment variable.\")\n    exit(1)\n\ntry:\n    credential = DefaultAzureCredential()\n    client = QuotaMgmtClient(credential=credential, subscription_id=subscription_id)\n\n    # Example: List Azure resource usages for a specific scope (e.g., location)\n    # The scope usually follows the format '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/locations/{location}'\n    # Or for a specific resource type: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}'\n    # For simplicity, listing operations are often tied to locations and resource providers.\n\n    # This is a simplified example. Real-world usage requires a valid scope.\n    # Example scope for listing regional quotas (requires specific resource provider and location)\n    # Replace 'eastus' and 'Microsoft.Compute' with your target location and resource provider.\n    # Note: Exact API calls and required parameters depend on the specific quota operation (e.g., list, get, create or update).\n\n    print(f\"Attempting to list quota operations for subscription: {subscription_id}\")\n    # Listing all operations is a general way to check service availability, actual quota calls are more specific.\n    # For actual quota listing, you'd typically target a specific resource provider and location.\n\n    # A more concrete example to get current usages for 'Microsoft.Compute' in 'eastus'\n    # This assumes the 'usages' operation group is available for the client and scope\n    # Please refer to the official SDK samples for detailed usage scenarios.\n    # The `usages` object might not be directly accessible on the base client; it's an operation group.\n    # Correct way to access operations might involve client.usages.list()\n\n    # As per 3.0.0, operation groups are added. Let's try a generic operation to ensure client creation works.\n    # A common operation is to list current quotas for a resource provider in a location.\n    # The exact method name might vary, check the SDK documentation or samples for `list` or `get` methods.\n    \n    # Placeholder for actual quota retrieval - this part varies significantly based on specific needs\n    # For instance, to list quotas for 'Microsoft.Compute' in 'eastus':\n    # It would look something like:\n    # scope = \"/subscriptions/{}/providers/Microsoft.Compute/locations/eastus\".format(subscription_id)\n    # current_quotas = client.usages.list(scope=scope)\n    # for usage in current_quotas:\n    #     print(f\"  Resource: {usage.name.value}, Current Value: {usage.current_value}, Limit: {usage.limit}\")\n\n    # Let's perform a simple operation that generally works if authentication is successful,\n    # such as listing available operations on the client.\n    # Note: `QuotaMgmtClient` may not have a direct `operations.list()` method.\n    # Actual quota listing requires specific `scope` and `providerName`.\n    # A safer quickstart is to ensure the client is initialized.\n\n    print(\"QuotaMgmtClient initialized successfully.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize the `QuotaMgmtClient` using `DefaultAzureCredential`. It relies on environment variables (`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_SUBSCRIPTION_ID`) for authentication. A simple client initialization is shown; actual quota operations (listing, getting, or updating quotas) require specific resource scopes and resource provider names, which are detailed in the official Azure SDK samples."},"warnings":[{"fix":"Review the official SDK documentation and samples for version 3.x. Adjust client instantiation and method calls to use the new operation groups and parameters as required.","message":"Version 3.0.0 introduced significant changes, including new parameters for `QuotaMgmtClient.__init__` (e.g., `cloud_setting`) and the addition of new operation groups like `group_quota_usages` and `group_quota_location_settings`. Code directly interacting with client initialization parameters or previously flat methods might break.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Upgrade your Python environment to 3.9 or higher.","message":"Support for Python 2.7 has officially ended for Azure SDK Python packages. Attempts to use `azure-mgmt-quota` with Python 2.7 will likely result in compatibility issues or failures.","severity":"deprecated","affected_versions":"<=2.x"},{"fix":"Migrate your authentication code to use `azure-identity`. Ensure `azure-identity` is installed and configure environment variables (AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID) or other credential types.","message":"Authenticating Azure management SDKs now primarily uses `azure-identity` credentials (e.g., `DefaultAzureCredential`). Older patterns involving `msrestazure` credentials are deprecated and may not work correctly or be as secure.","severity":"gotcha","affected_versions":"<3.0.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Request a quota increase through the Azure portal (Subscriptions -> Usage + quotas -> Request increase) or via Azure CLI/PowerShell.","cause":"This error indicates that the requested Azure resource deployment or operation would exceed the quota limits set for your subscription, resource group, or location in Azure. It is not an issue with the library itself but with Azure service limits.","error":"azure.core.exceptions.HttpResponseError: (QuotaExceeded) Operation results in exceeding quota limits..."},{"fix":"Ensure that the resource name passed to the `quota.get()` or similar methods exactly matches the canonical resource name. For names with spaces or underscores, test with both the raw string and potentially URL-encoded versions if the raw string fails. Refer to Azure resource documentation for correct naming conventions.","cause":"When specifying resource names, especially for VM families or SKUs, spaces or special characters might be URL-encoded incorrectly or not handled as expected by the API. The `get()` method might be sensitive to the exact string format.","error":"azure.core.exceptions.HttpResponseError: (InvalidResourceName) Name %60%60Standard%20NCASv3_T4%20Family%60%60 is not valid resource name."},{"fix":"Verify that the `subscription_id`, `location`, `resource_provider_namespace`, and other components forming the `scope` string are accurate and adhere to the expected Azure Resource Manager path format. Double-check resource IDs and names.","cause":"This typically occurs when the `scope` or `resource_name` provided to quota operations does not correspond to an existing or correctly formatted Azure resource path. Common causes include incorrect subscription ID, location, resource provider namespace, or resource type/name in the scope string.","error":"azure.core.exceptions.ResourceNotFoundError: Resource not found for URL..."}]}