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.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
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.ArtifactTagProperties(**kwargs)[source]

Model for storing properties of a single tag

Variables
  • can_delete (bool) – Delete Permissions for an artifact

  • can_write (bool) – Delete Permissions for an artifact

  • can_read (bool) – Delete Permissions for an artifact

  • can_list (bool) – Delete Permissions for an artifact

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

  • digest (str) – Digest for the tag

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

  • name (str) – Name of the image the tag corresponds to

  • repository (str) – Repository 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[TokenCredential] = None, **kwargs: Any)[source]

Create a ContainerRegistryClient from an ACR endpoint and a credential

Parameters
  • endpoint (str) – An ACR endpoint

  • credential (TokenCredential) – The credential with which to authenticate

Keyword Arguments

credential_scopes (List[str]) – URL for credential authentication if different from the default

Returns

None

Raises

None

Example:

Instantiate an instance of ContainerRegistryClient
from azure.containerregistry import ContainerRegistryClient
from azure.identity import DefaultAzureCredential

account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]

client = ContainerRegistryClient(account_url, DefaultAzureCredential())
close()None

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

delete_manifest(repository: str, tag_or_digest: str, **kwargs: Any)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

Return type

None

Raises

HttpResponseError

Example

from azure.containerregistry import ContainerRepositoryClient
from azure.identity import DefaultAzureCredential
account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRepositoryClient(account_url, DefaultAzureCredential())
client.delete_manifest("my_repository", "my_tag_or_digest")
delete_repository(repository: str, **kwargs: Any)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

HttpResponseError

Example:

Delete a repository from the ContainerRegistryClient
            client.delete_repository(repository_name, tag.name)
delete_tag(repository: str, tag: str, **kwargs: Any)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

HttpResponseError

Example

from azure.containerregistry import ContainerRepositoryClient
from azure.identity import DefaultAzureCredential
account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRepositoryClient(account_url, "my_repository", DefaultAzureCredential())
for artifact in client.list_tag_properties():
    client.delete_tag("my_repository", tag.name)
get_manifest_properties(repository: str, tag_or_digest: str, **kwargs: Any)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

Returns

ArtifactManifestProperties

Raises

ResourceNotFoundError

Example

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

Get the properties of a repository

Parameters

repository (str) – Name of the repository

Returns

RepositoryProperties

Raises

ResourceNotFoundError

get_tag_properties(repository: str, tag: str, **kwargs: Any)ArtifactTagProperties[source]

Get the properties for a tag

Parameters
  • repository (str) – Name of the repository

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

Returns

ArtifactTagProperties

Raises

ResourceNotFoundError

Example

from azure.containerregistry import ContainerRepositoryClient
from azure.identity import DefaultAzureCredential
account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRepositoryClient(account_url, "my_repository", DefaultAzureCredential())
for tag in client.list_tag_properties():
    tag_properties = client.get_tag_properties("my_repository", tag.name)
list_manifest_properties(repository: str, **kwargs: Any)ItemPaged[ArtifactManifestProperties][source]

List the artifacts for a repository

Parameters

repository (str) – Name of the repository

Keyword Arguments
  • order_by (ManifestOrder 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

ResourceNotFoundError

list_repository_names(**kwargs: Any)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

HttpResponseError

Example:

List repositories in a container registry account
account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
credential = DefaultAzureCredential()
client = ContainerRegistryClient(account_url, credential)

for repository in client.list_repository_names():
    print(repository)
list_tag_properties(repository: str, **kwargs: Any)ItemPaged[ArtifactTagProperties][source]

List the tags for a repository

Parameters

repository (str) – Name of the repository

Keyword Arguments
  • order_by (TagOrder 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]

Return type

ItemPaged

Raises

ResourceNotFoundError

Example

from azure.containerregistry import ContainerRepositoryClient
from azure.identity import DefaultAzureCredential
account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRepositoryClient(account_url, "my_repository", DefaultAzureCredential())
for tag in client.list_tag_properties():
    tag_properties = client.get_tag_properties("my_repository", tag.name)
update_manifest_properties(repository, tag_or_digest, properties, **kwargs)[source]
update_manifest_properties(repository, tag_or_digest, **kwargs)

Set the properties for a manifest

Parameters
Returns

ArtifactManifestProperties

Raises

ResourceNotFoundError

Example

from azure.containerregistry import ContainerRepositoryClient
from azure.identity import DefaultAzureCredential
account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRepositoryClient(account_url, "my_repository", DefaultAzureCredential())
for artifact in client.list_manifest_properties():
    received_properties = client.update_manifest_properties(
        "my_repository",
        artifact.digest,
        can_delete=False,
        can_list=False,
        can_read=False,
        can_write=False,
    )
update_repository_properties(repository, properties, **kwargs)[source]
update_repository_properties(repository, **kwargs)

Set the properties of a repository

Parameters
Returns

RepositoryProperties

Raises

ResourceNotFoundError

update_tag_properties(repository, tag, properties, **kwargs)[source]
update_tag_properties(repository, tag, **kwargs)

Set the properties for a tag

Parameters
Returns

ArtifactTagProperties

Raises

ResourceNotFoundError

Example

from azure.containerregistry import ContainerRepositoryClient, TagWriteableProperties
from azure.identity import DefaultAzureCredential
account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRepositoryClient(account_url, "my_repository", DefaultAzureCredential())
tag_identifier = "latest"
received = client.update_tag_properties(
    "my_repository",
    tag_identifier,
    can_delete=False,
    can_list=False,
    can_read=False,
    can_write=False,
)
class azure.containerregistry.ManifestOrder(value)[source]

Enum for ordering registry artifacts

LAST_UPDATE_TIME_ASCENDING = 'timeasc'
LAST_UPDATE_TIME_DESCENDING = 'timedesc'
class azure.containerregistry.RepositoryProperties(**kwargs)[source]

Model for storing properties of a single repository

Variables
  • can_delete (bool) – Delete Permissions for an artifact

  • can_write (bool) – Delete Permissions for an artifact

  • can_read (bool) – Delete Permissions for an artifact

  • can_list (bool) – Delete Permissions for an artifact

  • teleport_enabled (bool) – Teleport enabled for the repository

  • created_on (datetime.datetime) – Time the repository was created

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

  • manifest_count (int) – Number of manifest in the repository

  • name (str) – Name of the repository

  • tag_count (int) – Number of tags associated with the repository

property created_on
property last_udpated_on
property manifest_count
property name
property tag_count
class azure.containerregistry.TagOrder(value)[source]

Enum for ordering tags

LAST_UPDATE_TIME_ASCENDING = 'timeasc'
LAST_UPDATE_TIME_DESCENDING = 'timedesc'