/// <summary> /// </summary> public ContainerRegistryClient(Uri endpoint, TokenCredential credential, ContainerRegistryClientOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); Argument.AssertNotNull(options, nameof(options)); _endpoint = endpoint; _clientDiagnostics = new ClientDiagnostics(options); _acrAuthPipeline = HttpPipelineBuilder.Build(options); _acrAuthClient = new AuthenticationRestClient(_clientDiagnostics, _acrAuthPipeline, endpoint.AbsoluteUri); _pipeline = HttpPipelineBuilder.Build(options, new ContainerRegistryChallengeAuthenticationPolicy(credential, AcrAadScope, _acrAuthClient)); _restClient = new ContainerRegistryRestClient(_clientDiagnostics, _pipeline, _endpoint.AbsoluteUri); }
/// <summary> /// Initializes a new instance of the ContainerRegistryClient for managing container images and artifacts. /// </summary> /// <param name="registryUri">The URI endpoint of the container registry. This is likely to be similar /// to "https://{registry-name}.azurecr.io".</param> /// <param name="credential">The API key credential used to authenticate requests /// against the container registry. </param> /// <param name="options">Client configuration options for connecting to Azure Container Registry.</param> /// <exception cref="ArgumentNullException"> Thrown when the <paramref name="registryUri"/> or <paramref name="credential"/> is null. </exception> public ContainerRegistryClient(Uri registryUri, TokenCredential credential, ContainerRegistryClientOptions options) { Argument.AssertNotNull(registryUri, nameof(registryUri)); Argument.AssertNotNull(credential, nameof(credential)); Argument.AssertNotNull(options, nameof(options)); _registryUri = registryUri; _registryName = registryUri.Host.Split('.')[0]; _clientDiagnostics = new ClientDiagnostics(options); _acrAuthPipeline = HttpPipelineBuilder.Build(options); _acrAuthClient = new AuthenticationRestClient(_clientDiagnostics, _acrAuthPipeline, registryUri.AbsoluteUri); _pipeline = HttpPipelineBuilder.Build(options, new ContainerRegistryChallengeAuthenticationPolicy(credential, AcrAadScope, _acrAuthClient)); _restClient = new ContainerRegistryRestClient(_clientDiagnostics, _pipeline, _registryUri.AbsoluteUri); }
/// <summary> /// Initializes a new instance of the <see cref="ContainerRegistryClient"/> for managing container images and artifacts. /// </summary> /// <param name="endpoint">The URI endpoint of the container registry. This is likely to be similar /// to "https://{registry-name}.azurecr.io".</param> /// <param name="credential">The API key credential used to authenticate requests /// against the container registry. </param> /// <param name="options">Client configuration options for connecting to Azure Container Registry.</param> /// <exception cref="ArgumentNullException"> Thrown when the <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception> public ContainerRegistryClient(Uri endpoint, TokenCredential credential, ContainerRegistryClientOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); Argument.AssertNotNull(options, nameof(options)); if (options.Audience == null) { throw new InvalidOperationException("ContainerRegistryClientOptions.Audience property must be set to initialize ContainerRegistryClient."); } _endpoint = endpoint; _registryName = endpoint.Host.Split('.')[0]; _clientDiagnostics = new ClientDiagnostics(options); _acrAuthPipeline = HttpPipelineBuilder.Build(options); _acrAuthClient = new AuthenticationRestClient(_clientDiagnostics, _acrAuthPipeline, endpoint.AbsoluteUri); string defaultScope = options.Audience + "/.default"; _pipeline = HttpPipelineBuilder.Build(options, new ContainerRegistryChallengeAuthenticationPolicy(credential, defaultScope, _acrAuthClient)); _restClient = new ContainerRegistryRestClient(_clientDiagnostics, _pipeline, _endpoint.AbsoluteUri); }
/// <summary> /// Initializes a new instance of the ContainerRegistryClient for managing container images and artifacts, /// using anonymous access to the registry. Only operations that support anonymous access are enabled. Other service /// methods will throw <see cref="RequestFailedException"/> if called. /// </summary> /// <param name="endpoint">The URI endpoint of the container registry. This is likely to be similar /// to "https://{registry-name}.azurecr.io".</param> /// <param name="options">Client configuration options for connecting to Azure Container Registry.</param> /// <exception cref="ArgumentNullException"> Thrown when the <paramref name="endpoint"/> is null. </exception> public ContainerRegistryClient(Uri endpoint, ContainerRegistryClientOptions options) : this(endpoint, new ContainerRegistryAnonymousAccessCredential(), options) { }
/// <summary> /// <param name="endpoint"></param> /// <param name="repository"> Name of the image (including the namespace). </param> /// <param name="username"></param> /// <param name="password"></param> /// <param name="options"></param> /// </summary> public ContainerRepositoryClient(Uri endpoint, string repository, string username, string password, ContainerRegistryClientOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(repository, nameof(repository)); Argument.AssertNotNull(username, nameof(username)); Argument.AssertNotNull(password, nameof(password)); Argument.AssertNotNull(options, nameof(options)); _pipeline = HttpPipelineBuilder.Build(options, new BasicAuthenticationPolicy(username, password)); _clientDiagnostics = new ClientDiagnostics(options); Endpoint = endpoint; _repository = repository; _restClient = new ContainerRegistryRepositoryRestClient(_clientDiagnostics, _pipeline, Endpoint.AbsoluteUri); }
/// <summary> /// </summary> /// <param name="endpoint"></param> /// <param name="username"></param> /// <param name="password"></param> /// <param name="options"></param> public ContainerRegistryClient(Uri endpoint, string username, string password, ContainerRegistryClientOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(options, nameof(options)); // The HttpPipelineBuilder.Build method, builds up a pipeline with client options, and any number of additional policies. _pipeline = HttpPipelineBuilder.Build(options, new BasicAuthenticationPolicy(username, password)); _clientDiagnostics = new ClientDiagnostics(options); _endpoint = endpoint; _restClient = new RepositoryRestClient(_clientDiagnostics, _pipeline, _endpoint.AbsoluteUri); }
/// <summary> /// Initializes a new instance of the ContainerRegistryClient for managing container images and artifacts, /// using anonymous access to the registry. Only operations that support anonymous access are enabled. Other service /// methods will throw <see cref="RequestFailedException"/> if called. /// </summary> /// <param name="registryUri">The URI endpoint of the container registry. This is likely to be similar /// to "https://{registry-name}.azurecr.io".</param> /// <param name="options">Client configuration options for connecting to Azure Container Registry.</param> /// <exception cref="ArgumentNullException"> Thrown when the <paramref name="registryUri"/> is null. </exception> public ContainerRegistryClient(Uri registryUri, ContainerRegistryClientOptions options) : this(registryUri, new ContainerRegistryAnonymousAccessCredential(), options) { }