The Microsoft Azure Cost Management Client Library for Python allows developers to manage Azure cost and usage data programmatically. It provides access to features like querying cost data, managing budgets, and working with dimensions and exports. Currently at version 4.0.1, it follows the Azure SDK release cadence, with updates often tied to new API versions and general SDK guidelines.
pip install azure-mgmt-costmanagement azure-identityVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and then list existing budgets within a specified Azure subscription using the `CostManagementClient`. Ensure you have the `AZURE_SUBSCRIPTION_ID` environment variable set, and your Azure credentials configured (e.g., via `az login` or environment variables like `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_TENANT_ID`).
Update import paths and client instantiation logic. Refer to the official Azure SDK documentation for the new API surface.
Ensure that `time_period` and `type` are always provided when constructing `QueryDefinition` objects for queries.
Always install `azure-identity` alongside any `azure-mgmt-*` library: `pip install azure-mgmt-costmanagement azure-identity`.
Ensure the scope string is correctly formatted (e.g., `subscriptions/{subscriptionId}`, `subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}`) and the authenticated principal has the necessary 'Cost Management Contributor' or similar role.No dependency data recorded yet.