{"id":2877,"library":"azure-containerregistry","title":"Azure Container Registry Client Library","description":"The Microsoft Azure Container Registry Client Library for Python provides an interface to interact with Azure Container Registry (ACR) services. It allows developers to manage container images, repositories, and other artifacts stored in ACR. The library is currently at version 1.2.0 and follows the Azure SDK for Python's regular release cadence, ensuring updates and feature parity with the service.","status":"active","version":"1.2.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/containerregistry/azure-containerregistry","tags":["azure","cloud","container","registry","docker","oci"],"install":[{"cmd":"pip install azure-containerregistry azure-identity","lang":"bash","label":"Install core library and authentication"}],"dependencies":[{"reason":"Required for authentication with Azure services, including Azure Container Registry. Provides various credential types like DefaultAzureCredential.","package":"azure-identity","optional":false}],"imports":[{"symbol":"ContainerRegistryClient","correct":"from azure.containerregistry import ContainerRegistryClient"},{"note":"Required for authentication using Azure Identity.","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.containerregistry import ContainerRegistryClient\nfrom azure.identity import DefaultAzureCredential\n\n# Set your ACR endpoint, e.g., 'https://myregistry.azurecr.io'\nregistry_url = os.environ.get('AZURE_CONTAINER_REGISTRY_URL', 'https://yourregistryname.azurecr.io')\n\n# DefaultAzureCredential will try various authentication methods\n# (environment variables, managed identity, VS Code, Azure CLI, etc.)\ncredential = DefaultAzureCredential()\n\nclient = ContainerRegistryClient(endpoint=registry_url, credential=credential)\n\ntry:\n    print(f\"Listing repositories in {registry_url}:\")\n    for repository_name in client.list_repository_names():\n        print(f\"- {repository_name}\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\nfinally:\n    client.close()\n    credential.close()","lang":"python","description":"This quickstart demonstrates how to authenticate with Azure Container Registry using `DefaultAzureCredential` and then list all repository names within the specified registry. Ensure the `AZURE_CONTAINER_REGISTRY_URL` environment variable is set to your registry's URL (e.g., `https://myregistry.azurecr.io`) and that your authenticated identity has sufficient permissions (e.g., 'AcrPull' role)."},"warnings":[{"fix":"Ensure `pip install azure-identity` is run and that your environment variables are correctly configured for `DefaultAzureCredential`, or explicitly pass other credential types. Refer to Azure Identity documentation for detailed setup.","message":"Authentication with Azure Container Registry requires the `azure-identity` package and proper credential setup. `DefaultAzureCredential` is the recommended way, but relies on environment variables (e.g., `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_TENANT_ID`) or other configured Azure SDK authentication methods. Without correct setup, authentication will fail.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Verify that the Azure AD principal used for authentication has the necessary permissions granted on the Azure Container Registry resource in the Azure portal or via Azure CLI/PowerShell.","message":"The authenticated identity (e.g., service principal, managed identity, user account) must have appropriate Azure RBAC roles assigned to the Container Registry. Common roles include `AcrPull` (read-only), `AcrPush` (read/write), or `Owner`/`Contributor` for full management. Insufficient permissions will result in authorization errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If you intend to manage the ACR resource (e.g., create/delete registries, configure geo-replication), use `azure-mgmt-containerregistry`. If you need to push/pull images, list repositories, or manage manifests within an existing registry, use `azure-containerregistry`.","message":"This library (`azure-containerregistry`) is the data-plane client for interacting with repositories, images, and manifests. It should not be confused with the management-plane client (`azure-mgmt-containerregistry`), which is used for creating, updating, and deleting the Container Registry *resource itself*.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}