Azure Container Registry client library for Python¶
Azure Container Registry allows you to store and manage container images and artifacts in a private registry for all types of container deployments.
Use the client library for Azure Container Registry to:
List images or artifacts in a registry
Obtain metadata for images and artifacts, repositories and tags
Set read/write/delete properties on registry items
Delete images and artifacts, repositories and tags
Install the package¶
Install the Azure Container Registry client library for Python with pip:
pip install --pre azure-containerregistry
az acr create --name MyContainerRegistry --resource-group MyResourceGroup --location westus --sku Basic
Authenticate the client¶
The Azure Identity library provides easy Azure Active Directory support for authentication. The
DefaultAzureCredential assumes the
AZURE_CLIENT_SECRET environment variables are set, for more information refer to the Azure Identity environment variables section
# Create a ContainerRegistryClient that will authenticate through Active Directory from azure.containerregistry import ContainerRegistryClient from azure.identity import DefaultAzureCredential account_url = "https://mycontainerregistry.azurecr.io" audience = "https://management.azure.com" client = ContainerRegistryClient(account_url, DefaultAzureCredential(), audience=audience)
A registry stores Docker images and OCI Artifacts. An image or artifact consists of a manifest and layers. An image’s manifest describes the layers that make up the image, and is uniquely identified by its digest. An image can also be “tagged” to give it a human-readable alias. An image or artifact can have zero or more tags associated with it, and each tag uniquely identifies the image. A collection of images that share the same name but have different tags, is referred to as a repository.
For more information please see Container Registry Concepts.
This library uses the standard logging library for logging.
Basic information about HTTP sessions (URLs, headers, etc.) is logged at
DEBUG level logging, including request/response bodies and unredacted
headers, can be enabled on the client or per-operation with the
logging_enable keyword argument.
See full SDK logging documentation with examples here.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit cla.microsoft.com.