/// <summary> /// Creates a new instance of <see cref="AzureKeyVaultConfigurationProvider"/>. /// </summary> /// <param name="client">The <see cref="SecretClient"/> to use for retrieving values.</param> /// <param name="manager">The <see cref="KeyVaultSecretManager"/> to use in managing values.</param> /// <param name="reloadInterval">The timespan to wait in between each attempt at polling the Azure Key Vault for changes. Default is null which indicates no reloading.</param> public AzureKeyVaultConfigurationProvider(SecretClient client, KeyVaultSecretManager manager, TimeSpan?reloadInterval = null) { Argument.AssertNotNull(client, nameof(client)); Argument.AssertNotNull(manager, nameof(manager)); _client = client; _manager = manager; if (reloadInterval != null && reloadInterval.Value <= TimeSpan.Zero) { throw new ArgumentOutOfRangeException(nameof(reloadInterval), reloadInterval, nameof(reloadInterval) + " must be positive."); } _pollingTask = null; _cancellationToken = new CancellationTokenSource(); _reloadInterval = reloadInterval; }
/// <summary> /// Creates a new instance of <see cref="AzureKeyVaultConfigurationProvider"/>. /// </summary> /// <param name="client">The <see cref="SecretClient"/> to use for retrieving values.</param> /// <param name="options">The <see cref="AzureKeyVaultConfigurationOptions"/> to configure provider behaviors.</param> /// <exception cref="ArgumentNullException">When either <paramref name="client"/> or <see cref="AzureKeyVaultConfigurationOptions.Manager"/> is <code>null</code>.</exception> /// <exception cref="ArgumentOutOfRangeException">When either <see cref="AzureKeyVaultConfigurationOptions.ReloadInterval"/> is not positive or <code>null</code>.</exception> public AzureKeyVaultConfigurationProvider(SecretClient client, AzureKeyVaultConfigurationOptions options = null) { options ??= new AzureKeyVaultConfigurationOptions(); Argument.AssertNotNull(client, nameof(client)); Argument.AssertNotNull(options.Manager, $"{nameof(options)}.{nameof(options.Manager)}"); _client = client; if (options.ReloadInterval != null && options.ReloadInterval.Value <= TimeSpan.Zero) { throw new ArgumentOutOfRangeException(nameof(options.ReloadInterval), options.ReloadInterval, nameof(options.ReloadInterval) + " must be positive."); } _pollingTask = null; _cancellationToken = new CancellationTokenSource(); _reloadInterval = options.ReloadInterval; _manager = options.Manager; }