azure.containerregistry package

class azure.containerregistry.ArtifactArchitecture(value)[source]

An enumeration.

AMD64 = 'amd64'
ARM = 'arm'
ARM64 = 'arm64'
I386 = '386'
MIPS = 'mips'
MIPS64 = 'mips64'
MIPS64LE = 'mips64le'
MIPSLE = 'mipsle'
PPC64 = 'ppc64'
PPC64LE = 'ppc64le'
RISCV64 = 'riscv64'
S390X = 's390x'
WASM = 'wasm'
class azure.containerregistry.ArtifactManifestOrder(value)[source]

Sort options for ordering manifests in a collection.

LAST_UPDATED_ON_ASCENDING = 'timeasc'

Order manifest by LastUpdatedOn field, from least recently updated to most recently updated.

LAST_UPDATED_ON_DESCENDING = 'timedesc'

Order manifests by LastUpdatedOn field, from most recently updated to least recently updated.

NONE = 'none'

Do not provide an orderby value in the request.

class azure.containerregistry.ArtifactManifestProperties(**kwargs)[source]

Represents properties of a registry artifact.

Variables
property architecture
property created_on
property digest
property fully_qualified_reference
property last_updated_on
property operating_system
property repository_name
property size_in_bytes
property tags
class azure.containerregistry.ArtifactOperatingSystem(value)[source]

An enumeration.

AIX = 'aix'
ANDROID = 'android'
DARWIN = 'darwin'
DRAGONFLY = 'dragonfly'
FREEBSD = 'freebsd'
ILLUMOS = 'illumos'
IOS = 'ios'
JS = 'js'
LINUX = 'linux'
NETBSD = 'netbsd'
OPENBSD = 'openbsd'
PLAN9 = 'plan9'
SOLARIS = 'solaris'
WINDOWS = 'windows'
class azure.containerregistry.ArtifactTagOrder(value)[source]

Sort options for ordering tags in a collection.

LAST_UPDATED_ON_ASCENDING = 'timeasc'

Order tags by LastUpdatedOn field, from least recently updated to most recently updated.

LAST_UPDATED_ON_DESCENDING = 'timedesc'

Order tags by LastUpdatedOn field, from most recently updated to least recently updated.

NONE = 'none'

Do not provide an orderby value in the request.

class azure.containerregistry.ArtifactTagProperties(**kwargs)[source]

Represents properties of a single tag

Variables
  • can_delete (bool) – Delete Permissions for a tag.

  • can_write (bool) – Write Permissions for a tag.

  • can_read (bool) – Read Permissions for a tag.

  • can_list (bool) – List Permissions for a tag.

  • created_on (Optional[datetime]) – Time the tag was created.

  • digest (Optional[str]) – Digest for the tag.

  • last_updated_on (Optional[datetime]) – Time the tag was last updated.

  • name (Optional[str]) – Name of the image the tag corresponds to.

  • repository_name (Optional[str]) – Repository name the tag belongs to.

property created_on
property digest
property last_updated_on
property name
property repository_name
class azure.containerregistry.ContainerRegistryClient(endpoint: str, credential: Optional[azure.core.credentials.TokenCredential] = None, *, api_version: Optional[str] = None, audience: str = 'https://management.azure.com', **kwargs)[source]

Create a ContainerRegistryClient from an ACR endpoint and a credential.

Parameters
  • endpoint (str) – An ACR endpoint.

  • credential (TokenCredential or None) – The credential with which to authenticate. This should be None in anonymous access.

Keyword Arguments
Returns

None

Return type

None

Raises

ValueError – If the provided api_version keyword-only argument isn’t supported.

Example:

Instantiate an instance of ContainerRegistryClient
with ContainerRegistryClient(self.endpoint, self.credential, audience=self.audience) as client:
close()None

Close sockets opened by the client. Calling this method is unnecessary when using the client as a context manager.

delete_blob(repository: str, tag_or_digest: str, **kwargs)None[source]

Delete a blob. If the blob cannot be found or a response status code of 404 is returned an error will not be raised.

Parameters
  • repository (str) – Name of the repository the manifest belongs to

  • tag_or_digest (str) – Tag or digest of the blob to be deleted

Returns

None

Raises

~azure.core.exceptions.HttpResponseError

Example

from azure.containerregistry import ContainerRegistryClient
from azure.identity import DefaultAzureCredential
endpoint = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRegistryClient(endpoint, DefaultAzureCredential(), audience="my_audience")
client.delete_blob("my_repository", "my_tag_or_digest")
delete_manifest(repository: str, tag_or_digest: str, **kwargs)None[source]

Delete a manifest. If the manifest cannot be found or a response status code of 404 is returned an error will not be raised.

Parameters
  • repository (str) – Name of the repository the manifest belongs to

  • tag_or_digest (str) – Tag or digest of the manifest to be deleted

Returns

None

Raises

~azure.core.exceptions.HttpResponseError

Example

from azure.containerregistry import ContainerRegistryClient
from azure.identity import DefaultAzureCredential
endpoint = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRegistryClient(endpoint, DefaultAzureCredential(), audience="my_audience")
client.delete_manifest("my_repository", "my_tag_or_digest")
delete_repository(repository: str, **kwargs)None[source]

Delete a repository. If the repository cannot be found or a response status code of 404 is returned an error will not be raised.

Parameters

repository (str) – The repository to delete

Returns

None

Return type

None

Raises

~azure.core.exceptions.HttpResponseError

Example:

Delete a repository from the ContainerRegistryClient
            client.delete_repository(repository_name)
delete_tag(repository: str, tag: str, **kwargs)None[source]

Delete a tag from a repository. If the tag cannot be found or a response status code of 404 is returned an error will not be raised.

Parameters
  • repository (str) – Name of the repository the tag belongs to

  • tag (str) – The tag to be deleted

Returns

None

Return type

None

Raises

~azure.core.exceptions.HttpResponseError

Example

from azure.containerregistry import ContainerRegistryClient
from azure.identity import DefaultAzureCredential
endpoint = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRegistryClient(endpoint, DefaultAzureCredential(), audience="my_audience")
for tag in client.list_tag_properties("my_repository"):
    client.delete_tag("my_repository", tag.name)
download_blob(repository: str, digest: str, **kwargs)azure.containerregistry._models.DownloadBlobResult[source]

Download a blob that is part of an artifact.

Parameters
  • repository (str) – Name of the repository

  • digest (str) – The digest of the blob to download.

Returns

DownloadBlobResult

Return type

DownloadBlobResult

Raises

ValueError – If the parameter repository or digest is None.

download_manifest(repository: str, tag_or_digest: str, **kwargs)azure.containerregistry._models.DownloadManifestResult[source]

Download the manifest for an OCI artifact.

Parameters
  • repository (str) – Name of the repository

  • tag_or_digest (str) – The tag or digest of the manifest to download. When digest is provided, will use this digest to compare with the one calculated by the response payload. When tag is provided, will use the digest in response headers to compare.

Returns

DownloadManifestResult

Return type

DownloadManifestResult

Raises
  • ValueError – If the parameter repository or tag_or_digest is None.

  • HttpResponseError – If the requested digest does not match the digest of the received manifest.

get_manifest_properties(repository: str, tag_or_digest: str, **kwargs)azure.containerregistry._models.ArtifactManifestProperties[source]

Get the properties of a registry artifact

Parameters
  • repository (str) – Name of the repository

  • tag_or_digest (str) – Tag or digest of the manifest

Return type

ArtifactManifestProperties

Raises

~azure.core.exceptions.ResourceNotFoundError

Example

from azure.containerregistry import ContainerRegistryClient
from azure.identity import DefaultAzureCredential
endpoint = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRegistryClient(endpoint, DefaultAzureCredential(), audience="my_audience")
for artifact in client.list_manifest_properties("my_repository"):
    properties = client.get_manifest_properties("my_repository", artifact.digest)
get_repository_properties(repository: str, **kwargs)azure.containerregistry._models.RepositoryProperties[source]

Get the properties of a repository

Parameters

repository (str) – Name of the repository

Return type

RepositoryProperties

Raises

~azure.core.exceptions.ResourceNotFoundError

get_tag_properties(repository: str, tag: str, **kwargs)azure.containerregistry._models.ArtifactTagProperties[source]

Get the properties for a tag

Parameters
  • repository (str) – Name of the repository

  • tag (str) – The tag to get tag properties for

Return type

ArtifactTagProperties

Raises

~azure.core.exceptions.ResourceNotFoundError

Example

from azure.containerregistry import ContainerRegistryClient
from azure.identity import DefaultAzureCredential
endpoint = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRegistryClient(endpoint, DefaultAzureCredential(), audience="my_audience")
for tag in client.list_tag_properties("my_repository"):
    tag_properties = client.get_tag_properties("my_repository", tag.name)
list_manifest_properties(repository: str, **kwargs)azure.core.paging.ItemPaged[azure.containerregistry._models.ArtifactManifestProperties][source]

List the artifacts for a repository

Parameters

repository (str) – Name of the repository

Keyword Arguments
  • order_by (ArtifactManifestOrder or str) – Query parameter for ordering by time ascending or descending

  • results_per_page (int) – Number of repositories to return per page

Returns

An iterable of ArtifactManifestProperties

Return type

ItemPaged[ArtifactManifestProperties]

Raises

~azure.core.exceptions.ResourceNotFoundError

list_repository_names(**kwargs)azure.core.paging.ItemPaged[str][source]

List all repositories

Keyword Arguments

results_per_page (int) – Number of repositories to return per page

Returns

An iterable of strings

Return type

ItemPaged[str]

Raises

~azure.core.exceptions.HttpResponseError

Example:

List repositories in a container registry account
    for repository in client.list_repository_names():
        print(repository)
list_tag_properties(repository: str, **kwargs)azure.core.paging.ItemPaged[azure.containerregistry._models.ArtifactTagProperties][source]

List the tags for a repository

Parameters

repository (str) – Name of the repository

Keyword Arguments
  • order_by (ArtifactTagOrder or str) – Query parameter for ordering by time ascending or descending

  • results_per_page (int) – Number of repositories to return per page

Returns

An iterable of ArtifactTagProperties

Return type

ItemPaged[ArtifactTagProperties]

Raises

~azure.core.exceptions.ResourceNotFoundError

Example

from azure.containerregistry import ContainerRegistryClient
from azure.identity import DefaultAzureCredential
endpoint = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRegistryClient(endpoint, DefaultAzureCredential(), audience="my_audience")
for tag in client.list_tag_properties("my_repository"):
    tag_properties = client.get_tag_properties("my_repository", tag.name)
update_manifest_properties(repository: str, tag_or_digest: str, properties: ArtifactManifestProperties, **kwargs)ArtifactManifestProperties[source]
update_manifest_properties(repository: str, tag_or_digest: str, *, can_delete: Optional[bool] = 'None', can_list: Optional[bool] = 'None', can_read: Optional[bool] = 'None', can_write: Optional[bool] = 'None', **kwargs)ArtifactManifestProperties
update_repository_properties(repository: str, properties: RepositoryProperties, **kwargs)RepositoryProperties[source]
update_repository_properties(repository: str, *, can_delete: Optional[bool] = 'None', can_list: Optional[bool] = 'None', can_read: Optional[bool] = 'None', can_write: Optional[bool] = 'None', **kwargs)RepositoryProperties
update_tag_properties(repository: str, tag: str, properties: ArtifactTagProperties, **kwargs)ArtifactTagProperties[source]
update_tag_properties(repository: str, tag: str, *, can_delete: Optional[bool] = 'None', can_list: Optional[bool] = 'None', can_read: Optional[bool] = 'None', can_write: Optional[bool] = 'None', **kwargs)ArtifactTagProperties
upload_blob(repository: str, data: IO, **kwargs)str[source]

Upload an artifact blob.

Parameters
  • repository (str) – Name of the repository

  • data (IO) – The blob to upload. Note: This must be a seekable stream.

Returns

The digest of the uploaded blob, calculated by the registry.

Return type

str

Raises

ValueError – If the parameter repository or data is None.

upload_manifest(repository: str, manifest: Union[azure.containerregistry._generated.models._models.OCIManifest, IO], *, tag: Optional[str] = None, **kwargs)str[source]

Upload a manifest for an OCI artifact.

Parameters
  • repository (str) – Name of the repository

  • manifest (OCIManifest or IO) – The manifest to upload. Note: This must be a seekable stream.

Keyword Arguments

tag (str or None) – Tag of the manifest.

Returns

The digest of the uploaded manifest, calculated by the registry.

Return type

str

Raises
  • ValueError – If the parameter repository or manifest is None.

  • HttpResponseError – If the digest in the response does not match the digest of the uploaded manifest.

class azure.containerregistry.RepositoryProperties(**kwargs)[source]

Represents properties of a single repository.

Variables
  • can_delete (bool) – Delete Permissions for a repository.

  • can_write (bool) – Write Permissions for a repository.

  • can_read (bool) – Read Permissions for a repository.

  • can_list (bool) – List Permissions for a repository.

  • created_on (Optional[datetime]) – Time the repository was created

  • last_updated_on (Optional[datetime]) – Time the repository was last updated.

  • manifest_count (Optional[int]) – Number of manifest in the repository.

  • name (Optional[str]) – Name of the repository.

  • tag_count (Optional[int]) – Number of tags associated with the repository.

property created_on
property last_updated_on
property manifest_count
property name
property tag_count