The `azure-mgmt-subscription` library provides Python APIs for managing Azure subscriptions. It allows developers to programmatically interact with Azure to get subscription details, list available locations, manage subscription aliases, and perform other subscription-related operations. The current stable version is 3.1.1. The Azure SDK for Python generally follows an active release cadence for its management libraries, with updates addressing bug fixes, new features, and breaking changes across major versions.
pip install azure-mgmt-subscription azure-identityVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and then use `SubscriptionClient` to list all accessible subscriptions, retrieve details for a specific subscription, and list available locations within that subscription.
Review the migration guide if upgrading from pre-3.0.0 versions. Update long-running operation calls to use `begin_` prefix and `azure.core.polling.LROPoller`. Handle `HttpResponseError` instead of `CloudError`.
Update import statements: `from azure.mgmt.subscription import SubscriptionClient` and `from azure.mgmt.subscription.models import ModelName`.
Ensure your Python environment is running Python 3.7 or newer. For new projects, consider Python 3.9+.
Before initiating a subscription transfer, verify and if necessary, adjust the Microsoft Entra tenant association for both subscriptions to match.
Migrate any classic resources to Azure Resource Manager before attempting to move the subscription. This can be a complex process depending on the resources involved.
Upgrade to `azure-mgmt-subscription==3.1.1` or newer. If stuck on 3.1.0, you might need to explicitly pass the `api_version` keyword argument to affected operations.