/// <summary> /// Initializes a new instance of the SecretClient class. /// </summary> /// <param name="vaultUri">Endpoint URL for the Azure Key Vault service.</param> /// <param name="credential">Represents a credential capable of providing an OAuth token.</param> /// <param name="options">Options that allow to configure the management of the request sent to Key Vault.</param> public SecretClient(Uri vaultUri, TokenCredential credential, SecretClientOptions options) { _vaultUri = vaultUri ?? throw new ArgumentNullException(nameof(credential)); options = options ?? new SecretClientOptions(); this.ApiVersion = options.GetVersionString(); _pipeline = HttpPipelineBuilder.Build(options, new ChallengeBasedAuthenticationPolicy(credential)); }
/// <summary> /// Initializes a new instance of the SecretClient class. /// </summary> /// <param name="vaultUri">Endpoint URL for the Azure Key Vault service.</param> /// <param name="credential">Represents a credential capable of providing an OAuth token.</param> /// <param name="options">Options that allow to configure the management of the request sent to Key Vault.</param> public SecretClient(Uri vaultUri, TokenCredential credential, SecretClientOptions options) { _vaultUri = vaultUri ?? throw new ArgumentNullException(nameof(credential)); options = options ?? new SecretClientOptions(); this.ApiVersion = options.GetVersionString(); _pipeline = HttpPipelineBuilder.Build(options, bufferResponse: true, new BearerTokenAuthenticationPolicy(credential, "https://vault.azure.net/.default")); }
/// <summary> /// Initializes a new instance of the <see cref="SecretClient"/> class for the specified vault. /// </summary> /// <param name="vaultUri">A <see cref="Uri"/> to the vault on which the client operates. Appears as "DNS Name" in the Azure portal.</param> /// <param name="credential">A <see cref="TokenCredential"/> used to authenticate requests to the vault, such as DefaultAzureCredential.</param> /// <param name="options"><see cref="SecretClientOptions"/> that allow to configure the management of the request sent to Key Vault.</param> /// <exception cref="ArgumentNullException"><paramref name="vaultUri"/> or <paramref name="credential"/> is null.</exception> public SecretClient(Uri vaultUri, TokenCredential credential, SecretClientOptions options) { Argument.AssertNotNull(vaultUri, nameof(vaultUri)); Argument.AssertNotNull(credential, nameof(credential)); options ??= new SecretClientOptions(); string apiVersion = options.GetVersionString(); HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new ChallengeBasedAuthenticationPolicy(credential)); _pipeline = new KeyVaultPipeline(vaultUri, apiVersion, pipeline, new ClientDiagnostics(options)); }
/// <summary> /// Initializes a new instance of the SecretClient class. /// </summary> /// <param name="vaultUri">Endpoint URL for the Azure Key Vault service.</param> /// <param name="credential">Represents a credential capable of providing an OAuth token.</param> /// <param name="options">Options that allow to configure the management of the request sent to Key Vault.</param> /// <exception cref="ArgumentNullException"><paramref name="vaultUri"/> or <paramref name="credential"/> is null.</exception> public SecretClient(Uri vaultUri, TokenCredential credential, SecretClientOptions options) { _vaultUri = vaultUri ?? throw new ArgumentNullException(nameof(vaultUri)); if (credential is null) { throw new ArgumentNullException(nameof(credential)); } options ??= new SecretClientOptions(); string apiVersion = options.GetVersionString(); HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new ChallengeBasedAuthenticationPolicy(credential)); _pipeline = new KeyVaultPipeline(_vaultUri, apiVersion, pipeline); }