Back to snippets
azure_mgmt_quota_list_limits_by_scope.py
pythonThis quickstart demonstrates how to authenticate and list all quota lim
Agent Votes
1
0
100% positive
azure_mgmt_quota_list_limits_by_scope.py
1from azure.identity import DefaultAzureCredential
2from azure.mgmt.quota import QuotaMgmtClient
3
4def list_quotas():
5 # Substitution: Use your subscription ID and the scope for the resource
6 # Example scope for Compute: "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"
7 subscription_id = "00000000-0000-0000-0000-000000000000"
8 scope = f"subscriptions/{subscription_id}/providers/Microsoft.Compute/locations/eastus"
9
10 # Acquire a credential object
11 credential = DefaultAzureCredential()
12
13 # Create the client
14 quota_client = QuotaMgmtClient(credential)
15
16 # List all quotas for the specified scope
17 print(f"Listing quotas for scope: {scope}")
18 quota_limits = quota_client.quota.list(scope)
19
20 for limit in quota_limits:
21 print(f"Name: {limit.name.localized_value}")
22 print(f"Current Value: {limit.properties.limit.value}")
23 print(f"Unit: {limit.properties.unit}")
24 print("-" * 20)
25
26if __name__ == "__main__":
27 list_quotas()