Azure Managed Services Management Client Library
The `azure-mgmt-managedservices` library is the Microsoft Azure Managed Services Client Library for Python, part of the Azure Resource Manager (ARM) generation of management APIs. It allows developers to programmatically interact with Azure Managed Services, such as managing registration definitions and assignments. The current stable version is 6.0.0, released in April 2021. Azure SDKs typically follow a consistent release cadence with updates across various services.
Warnings
- breaking The credential system underwent a complete revamp in version 6.0.0 (and its beta predecessors). Classes like `azure.common.credentials` or `msrestazure.azure_active_directory` are no longer supported. You *must* use classes from the `azure-identity` package, such as `DefaultAzureCredential`.
- breaking The `config` attribute is no longer directly available on client objects. Configuration options should be passed as keyword arguments during client initialization.
- breaking Operations that previously returned `msrest.polling.LROPoller` for long-running operations now return `azure.core.polling.LROPoller`.
- deprecated Support for Python 2.7 has officially ended for Azure SDK Python packages as of January 1, 2022. While version 6.0.0 might have been tested with older Python 3 versions at release, current active support targets Python 3.8+.
- gotcha For long-running operations (LROs), the client will return a poller object. You must call `.result()` on the poller to wait for the operation to complete and get its final result. For asynchronous clients (found in the `aio` namespace), you'll use `await poller.result()`.
Install
-
pip install azure-mgmt-managedservices azure-identity
Imports
- ManagedServicesClient
from azure.mgmt.managedservices import ManagedServicesClient
- DefaultAzureCredential
from azure.common.credentials import ServicePrincipalCredentials
from azure.identity import DefaultAzureCredential
Quickstart
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.managedservices import ManagedServicesClient
# Set your Azure Subscription ID as an environment variable
# AZURE_SUBSCRIPTION_ID = "YOUR_SUBSCRIPTION_ID"
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "")
if not subscription_id:
raise ValueError("AZURE_SUBSCRIPTION_ID environment variable not set.")
# Authenticate using DefaultAzureCredential. This will try various methods:
# AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID environment variables,
# Managed Identity, Azure CLI, Visual Studio Code, etc.
credential = DefaultAzureCredential()
# Create a ManagedServicesClient
client = ManagedServicesClient(credential, subscription_id)
# List registration definitions (example operation)
print("Listing registration definitions:")
for rd in client.registration_definitions.list():
print(f" - {rd.id}: {rd.name}")