Class ContainerRegistryClientBuilder

java.lang.Object
com.azure.containers.containerregistry.ContainerRegistryClientBuilder
All Implemented Interfaces:
ConfigurationTrait<ContainerRegistryClientBuilder>, EndpointTrait<ContainerRegistryClientBuilder>, HttpTrait<ContainerRegistryClientBuilder>, TokenCredentialTrait<ContainerRegistryClientBuilder>

This class provides a fluent builder API to help aid the configuration and instantiation of ContainerRegistryClients and ContainerRegistryAsyncClients, call buildClient and buildAsyncClient respectively to construct an instance of the desired client.

The client needs the service endpoint of the Azure Container Registry, Audience for ACR that you want to target and Azure access credentials to use for authentication.

Instantiating an asynchronous Container Registry client

 ContainerRegistryAsyncClient registryAsyncClient = new ContainerRegistryClientBuilder()
     .endpoint(endpoint)
     .credential(credential)
     .audience(ContainerRegistryAudience.AZURE_RESOURCE_MANAGER_PUBLIC_CLOUD)
     .buildAsyncClient();
 

Instantiating a synchronous Container Registry client

 ContainerRegistryClient registryAsyncClient = new ContainerRegistryClientBuilder()
     .endpoint(endpoint)
     .audience(ContainerRegistryAudience.AZURE_RESOURCE_MANAGER_PUBLIC_CLOUD)
     .credential(credential)
     .buildClient();
 

Another way to construct the client is using a HttpPipeline. The pipeline gives the client an authenticated way to communicate with the service but it doesn't contain the service endpoint. Set the pipeline with this and set the service endpoint with this. Using a pipeline requires additional setup but allows for finer control on how the ContainerRegistryClient and ContainerRegistryAsyncClient is built.

The service does not directly support AAD credentials and as a result the clients internally depend on a policy that converts the AAD credentials to the Azure Container Registry specific service credentials. In case you use your own pipeline, you would need to provide implementation for this policy as well. For more information please see Azure Container Registry Authentication .

Instantiating an asynchronous Container Registry client using a custom pipeline

 HttpPipeline pipeline = new HttpPipelineBuilder()
     .policies(/* add policies */)
     .build();

 ContainerRegistryAsyncClient registryAsyncClient = new ContainerRegistryClientBuilder()
     .pipeline(pipeline)
     .endpoint(endpoint)
     .audience(ContainerRegistryAudience.AZURE_RESOURCE_MANAGER_PUBLIC_CLOUD)
     .credential(credential)
     .buildAsyncClient();
 

Instantiating a synchronous Container Registry client with custom pipeline

 HttpPipeline pipeline = new HttpPipelineBuilder()
     .policies(/* add policies */)
     .build();

 ContainerRegistryClient registryAsyncClient = new ContainerRegistryClientBuilder()
     .pipeline(pipeline)
     .endpoint(endpoint)
     .audience(ContainerRegistryAudience.AZURE_RESOURCE_MANAGER_PUBLIC_CLOUD)
     .credential(credential)
     .buildClient();
 
See Also: