ContainerRegistryClient class

The client class used to interact with the Container Registry service.

Constructors

ContainerRegistryClient(string, ContainerRegistryClientOptions)

Creates an instance of a ContainerRegistryClient to interact with an Azure Container Registry that has anonymous pull access enabled. Only operations that support anonymous access are enabled. Other service methods will throw errors.

Example usage:

import { ContainerRegistryClient } from "@azure/container-registry";

const client = new ContainerRegistryClient(
   "<container registry API endpoint>",
);
ContainerRegistryClient(string, TokenCredential, ContainerRegistryClientOptions)

Creates an instance of a ContainerRegistryClient.

Example usage:

import { ContainerRegistryClient } from "@azure/container-registry";
import { DefaultAzureCredential} from "@azure/identity";

const client = new ContainerRegistryClient(
   "<container registry API endpoint>",
   new DefaultAzureCredential()
);

Properties

endpoint

The Azure Container Registry endpoint.

Methods

deleteRepository(string, DeleteRepositoryOptions)

Deletes the repository identified by the given name and all associated artifacts.

getArtifact(string, string)

Returns an instance of RegistryArtifact for calling service methods related to the artifact specified by repositoryName and tagOrDigest.

getRepository(string)

Returns an instance of ContainerRepository for calling service methods related to the repository specified by repositoryName.

listRepositoryNames(ListRepositoriesOptions)

Returns an async iterable iterator to list names of repositories in this registry.

Example usage:

let client = new ContainerRegistryClient(url, credential);
for await (const repository of client.listRepositoryNames()) {
  console.log("repository name: ", repository);
}

Example using iter.next():

let iter = client.listRepositoryNames();
let item = await iter.next();
while (!item.done) {
  console.log(`repository name: ${item.value}`);
  item = await iter.next();
}

Example using byPage():

const pages = client.listRepositoryNames().byPage({ maxPageSize: 2 });
let page = await pages.next();
let i = 1;
while (!page.done) {
 if (page.value) {
   console.log(`-- page ${i++}`);
   for (const name of page.value) {
     console.log(`  repository name: ${name}`);
   }
 }
 page = await pages.next();
}

Constructor Details

ContainerRegistryClient(string, ContainerRegistryClientOptions)

Creates an instance of a ContainerRegistryClient to interact with an Azure Container Registry that has anonymous pull access enabled. Only operations that support anonymous access are enabled. Other service methods will throw errors.

Example usage:

import { ContainerRegistryClient } from "@azure/container-registry";

const client = new ContainerRegistryClient(
   "<container registry API endpoint>",
);
new ContainerRegistryClient(endpoint: string, options?: ContainerRegistryClientOptions)

Parameters

endpoint

string

the URL endpoint of the container registry

options
ContainerRegistryClientOptions

optional configuration used to send requests to the service

ContainerRegistryClient(string, TokenCredential, ContainerRegistryClientOptions)

Creates an instance of a ContainerRegistryClient.

Example usage:

import { ContainerRegistryClient } from "@azure/container-registry";
import { DefaultAzureCredential} from "@azure/identity";

const client = new ContainerRegistryClient(
   "<container registry API endpoint>",
   new DefaultAzureCredential()
);
new ContainerRegistryClient(endpoint: string, credential: TokenCredential, options?: ContainerRegistryClientOptions)

Parameters

endpoint

string

the URL endpoint of the container registry

credential
TokenCredential

used to authenticate requests to the service

options
ContainerRegistryClientOptions

optional configuration used to send requests to the service

Property Details

endpoint

The Azure Container Registry endpoint.

endpoint: string

Property Value

string

Method Details

deleteRepository(string, DeleteRepositoryOptions)

Deletes the repository identified by the given name and all associated artifacts.

function deleteRepository(repositoryName: string, options?: DeleteRepositoryOptions): Promise<void>

Parameters

repositoryName

string

the name of repository to delete

options
DeleteRepositoryOptions

optional configuration for the operation

Returns

Promise<void>

getArtifact(string, string)

Returns an instance of RegistryArtifact for calling service methods related to the artifact specified by repositoryName and tagOrDigest.

function getArtifact(repositoryName: string, tagOrDigest: string): RegistryArtifact

Parameters

repositoryName

string

the name of repository

tagOrDigest

string

tag or digest of the artifact to retrieve

Returns

getRepository(string)

Returns an instance of ContainerRepository for calling service methods related to the repository specified by repositoryName.

function getRepository(repositoryName: string): ContainerRepository

Parameters

repositoryName

string

the name of repository

Returns

listRepositoryNames(ListRepositoriesOptions)

Returns an async iterable iterator to list names of repositories in this registry.

Example usage:

let client = new ContainerRegistryClient(url, credential);
for await (const repository of client.listRepositoryNames()) {
  console.log("repository name: ", repository);
}

Example using iter.next():

let iter = client.listRepositoryNames();
let item = await iter.next();
while (!item.done) {
  console.log(`repository name: ${item.value}`);
  item = await iter.next();
}

Example using byPage():

const pages = client.listRepositoryNames().byPage({ maxPageSize: 2 });
let page = await pages.next();
let i = 1;
while (!page.done) {
 if (page.value) {
   console.log(`-- page ${i++}`);
   for (const name of page.value) {
     console.log(`  repository name: ${name}`);
   }
 }
 page = await pages.next();
}
function listRepositoryNames(options?: ListRepositoriesOptions): PagedAsyncIterableIterator<string, RepositoryPageResponse, PageSettings>

Parameters

Returns