Esempio n. 1
0
 // This is a stub implementation. We would use the AzureKeyVault SDK here for a production app.
 public Task <string> Handle(GetKeyVaultSecret request, CancellationToken cancellationToken)
 {
     if (KeyVaultSecrets.TryGetValue(request.SecretName, out var value))
     {
         return(Task.FromResult(value));
     }
     throw new KeyNotFoundException($"{request.SecretName} cannot be found.");
 }
        public void OptionsTests()
        {
            var options = new SecretClientOptions(SecretClientOptions.ServiceVersion.V7_1);

            KeyVaultSecrets.ConfigureDiagnostics(options, "app1", true, true, true, true, 2000);
            KeyVaultSecrets.ConfigureRetries(options, RetryMode.Fixed, 3, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(4), TimeSpan.FromMinutes(2));

            Assert.IsTrue(options.Retry.Delay == TimeSpan.FromMinutes(1), "Delay not expected");
            Assert.IsTrue(options.Retry.MaxDelay == TimeSpan.FromMinutes(4), "Maximum delay not expected");
            Assert.IsTrue(options.Retry.NetworkTimeout == TimeSpan.FromMinutes(2), "Network timeout not expected");
            Assert.IsTrue(options.Retry.MaxRetries == 3, "Maximum retries not expected");
            Assert.IsTrue(options.Retry.Mode == RetryMode.Fixed, "Retry mode not expected");

            Assert.IsTrue(options.Diagnostics.IsLoggingContentEnabled, "Is logging content enabled not expected");
            Assert.IsTrue(options.Diagnostics.IsLoggingEnabled, "Is logging enabled not expected");
            Assert.IsTrue(options.Diagnostics.IsTelemetryEnabled, "Is telemetry enabled not expected");
            Assert.IsTrue(options.Diagnostics.IsDistributedTracingEnabled, "Is distributed tracing enabled not expected");
            Assert.IsTrue(options.Diagnostics.LoggedContentSizeLimit == 2000, "Logging content size not expected");
            Assert.IsTrue(string.Equals(options.Diagnostics.ApplicationId, "app1", StringComparison.Ordinal), "Application id not expected");
        }