The Microsoft Azure Monitor Client Library for Python allows you to manage Azure Monitor resources, including metric definitions, metrics, activity logs, diagnostic settings, and alerts. It's part of the Azure SDK for Python, which follows a predictable release cadence with frequent updates across its many client libraries.
pip install azure-mgmt-monitor azure-identityVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and then use `MonitorManagementClient` to list diagnostic settings categories available at the subscription level. This helps verify client instantiation and basic API interaction.
For versions <7.0.0, refer to the older documentation. For >=7.0.0, use `azure.identity` for authentication and note the client methods `begin_long_running_operation()` for async operations and direct iteration for paged lists. Most breaking changes were in the 1.x -> 2.x transition for `azure-mgmt-monitor` (and similar for other `azure-mgmt-*` libraries), with 7.0.0 being a stable Track 2 release.
Always use the `azure-identity` library. `DefaultAzureCredential` is recommended for local development and `ManagedIdentityCredential` or `ServicePrincipalCredential` (with environment variables) for production. Ensure you are logged in via `az login` for `AzureCliCredential` to work, or set up appropriate environment variables for other credential types.
Always construct or retrieve the full resource ID in the format `/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}` for operations that target specific resources. The `resource_uri` parameter is common for this.Choose either the synchronous or asynchronous client (`MonitorManagementClient` or `MonitorManagementClientAsync`) at the beginning and stick to it. Asynchronous clients require an `async`/`await` context.