This is the Microsoft Azure Consumption Client Library. It allows programmatic management of consumption resources for Azure Enterprise Subscriptions, providing APIs to retrieve usage details, budgets, reservations, and other cost management data. The library is currently at version 10.0.0 and receives regular updates as part of the broader Azure SDK for Python.
pip install azure-mgmt-consumption azure-identityVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes the ConsumptionManagementClient using `DefaultAzureCredential` and lists the first 10 usage details for a specified subscription. Ensure `AZURE_SUBSCRIPTION_ID` and other Azure authentication environment variables (e.g., `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_TENANT_ID`) are set for `DefaultAzureCredential` to work. The example includes a basic filter for a specific month.
Migrate authentication code to use `azure-identity`. Example: `from azure.identity import DefaultAzureCredential; credential = DefaultAzureCredential(); client = ConsumptionManagementClient(credential, subscription_id)`.
Update all calls to model constructors or methods to use `key=value` syntax instead of positional arguments.
Review the specific operation signatures in the documentation for version 10.0.0 and adjust parameter usage accordingly, especially for filtering and scoping reservations and budgets.
For MCA subscriptions, try using the `billingPeriodName` parameter instead of date-based filters or consult Azure Support to understand historical data access limitations for your specific subscription type.
Import from `azure.mgmt.consumption.aio` and ensure your application code correctly uses `async`/`await` with an `AsyncTokenCredential` (e.g., `AsyncDefaultAzureCredential` from `azure.identity.aio`).