Install & Compatibility
Where this runs
tested against v? · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ResourceManagementClient
✓ from azure.mgmt.resource import ResourceManagementClient
✗ from azure.mgmt import ResourceManagementClient
The `azure-mgmt` package is a meta-package. Client classes are found in specific sub-packages (e.g., `azure.mgmt.resource`, `azure.mgmt.compute`), not directly under `azure.mgmt`.
DefaultAzureCredential
✓ from azure.identity import DefaultAzureCredential
Authentication classes are provided by the separate `azure-identity` package, which must be installed alongside `azure-mgmt` or its sub-packages.
This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and list all resource groups within a specified subscription. It requires the `AZURE_SUBSCRIPTION_ID` environment variable to be set and the `azure-identity` package installed. The `ResourceManagementClient` is imported from `azure.mgmt.resource`, which is part of the `azure-mgmt` meta-package.
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import ResourceManagementClient
# Set your Azure Subscription ID as an environment variable
# E.g., export AZURE_SUBSCRIPTION_ID='YOUR_SUBSCRIPTION_ID'
subscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', '')
if not subscription_id:
print("Please set the AZURE_SUBSCRIPTION_ID environment variable.")
else:
try:
# Authenticate using DefaultAzureCredential (looks for env vars, managed identity, etc.)
credential = DefaultAzureCredential()
# Create a ResourceManagementClient
resource_client = ResourceManagementClient(credential, subscription_id)
print(f"Listing resource groups in subscription: {subscription_id}")
for rg in resource_client.resource_groups.list():
print(f"- {rg.name} ({rg.location})")
except Exception as e:
print(f"An error occurred: {e}")
print("Ensure you have authenticated (e.g., `az login` or appropriate environment variables).")
Debug
Known issues
breakingMajor API redesign between 'Track 1' (older) and 'Track 2' (current) versions. `azure-mgmt` versions 5.0.0 and later are 'Track 2' which includes unified authentication, asynchronous support, and consistent client construction. Code written for older `azure-mgmt` versions (pre-5.0.0) will not be compatible.fixRefer to the Azure SDK for Python migration guide for detailed steps on updating client instantiation, authentication, and operation calls. This often involves changes in imports (e.g., `azure.mgmt.resource` instead of `azure.mgmt.resource.resources`), credential handling (using `azure-identity`), and method signatures.
affects: < 5.0.0 vs >= 5.0.0
gotchaThe `azure-mgmt` package is a meta-package that installs *all* individual `azure-mgmt-xxx` packages (e.g., `azure-mgmt-resource`, `azure-mgmt-compute`). While convenient, this can lead to a large number of dependencies. For production applications, it is often more efficient to install only the specific `azure-mgmt-SERVICE_NAME` packages required.fixInstead of `pip install azure-mgmt`, install specific packages like `pip install azure-mgmt-resource azure-mgmt-compute azure-identity` to reduce the dependency footprint and potential for conflicts.
affects: All versions of `azure-mgmt`.
gotchaAuthentication is handled by the separate `azure-identity` library. `azure-mgmt` client libraries do not include authentication mechanisms directly. Attempting to use clients without an `azure-identity` credential object will result in authentication errors.fixAlways install `azure-identity` (`pip install azure-identity`) and pass a credential object (e.g., `DefaultAzureCredential()`) to the client constructor.
affects: All versions of `azure-mgmt`.
Upgrade
Version history
5.0.0latest on PyPI · released Apr 8, 2020
Audit
Dependencies
No dependency data recorded yet.