Azure Container Registry Management Client Library
The Microsoft Azure Container Registry Management Client Library for Python facilitates programmatic interaction with Azure Container Registry resources. It allows developers to manage container registries, replications, webhooks, tasks, and other associated components within Azure. The library is currently at version 15.0.0, actively maintained as part of the broader Azure SDK for Python, and follows a frequent release cadence to support the latest Azure API versions. [1, 6, 9, 10, 15]
Warnings
- breaking Breaking change in 15.0.0: Some APIs related to container registry tasks have been moved to a new, more focused package: `azure-mgmt-containerregistrytasks`. If your application uses these APIs, you must migrate to the new package. [1, 2]
- breaking Breaking change in 15.0.0: The credential system has been completely revamped. Older authentication methods like `azure.common.credentials` or `msrestazure.azure_active_directory` are no longer supported. The `credentials` parameter for client initialization has been renamed to `credential`. [1]
- breaking Breaking change in 15.0.0 and subsequent versions: The package now exclusively targets the latest API-Version available on Azure, removing APIs from older versions to reduce package size. [1]
- breaking Breaking change in 15.0.0: Introduction of new 'hybrid models' which possess both dictionary and model nature. This might impact how you access or manipulate model properties. [1, 2]
- breaking Breaking change in 15.0.0: Several model instance variables, such as `location` and `tags` on the `Resource` model, have been deleted or renamed. Other models like `ActiveDirectoryObject` and `ConnectedRegistryPropertiesActivation` might also have been removed or renamed. [2]
- deprecated Older Azure SDK libraries that do not conform to current SDK guidelines are being deprecated. While they might still function, they will no longer receive official support and updates. [18]
Install
-
pip install azure-mgmt-containerregistry azure-identity
Imports
- ContainerRegistryManagementClient
from azure.mgmt.containerregistry import ContainerRegistryManagementClient
- DefaultAzureCredential
from azure.identity import DefaultAzureCredential
Quickstart
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerregistry import ContainerRegistryManagementClient
# Set your Azure Subscription ID as an environment variable (e.g., AZURE_SUBSCRIPTION_ID)
# Set other Azure Identity related environment variables (e.g., AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET)
# For more info: https://learn.microsoft.com/en-us/azure/developer/python/sdk/authentication-overview
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "your_subscription_id")
if subscription_id == "your_subscription_id":
print("Please set the AZURE_SUBSCRIPTION_ID environment variable.")
else:
# Authenticate using DefaultAzureCredential
# This credential will attempt to authenticate via environment variables, managed identity, Azure CLI, etc.
credential = DefaultAzureCredential()
# Create a ContainerRegistryManagementClient
client = ContainerRegistryManagementClient(credential, subscription_id)
# Example: List all container registries in the subscription
print(f"Listing container registries in subscription: {subscription_id}")
for registry in client.registries.list():
print(f" - {registry.name} (Location: {registry.location})")