Azure Container Registry Management Client Library

15.0.0 · active · verified Mon Apr 06

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

Install

Imports

Quickstart

This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and then list all Azure Container Registries within a specified subscription. Ensure you have the necessary environment variables set for Azure authentication (e.g., `AZURE_SUBSCRIPTION_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`). [7, 14]

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})")

view raw JSON →