Esempio n. 1
0
        public IConfigurationBuilder AddKeyVaultToConfigurationInner(
            IConfigurationBuilder configurationBuilder,
            string vaultName)
        {
            SecretClient secretClient =
                SecretClientFactory.CreateSecretClient(vaultName);

            configurationBuilder.AddAzureKeyVault(
                secretClient,
                new KeyVaultSecretManager());
            return(configurationBuilder);
        }
Esempio n. 2
0
        private async Task <string?> GetSecretAsync(string vaultName, string key)
        {
            SecretClient client = SecretClientFactory.CreateSecretClient(vaultName);

            try
            {
                Response <KeyVaultSecret> secret = await client
                                                   .GetSecretAsync($"{key}");

                return(secret.Value.Value);
            }
            catch (RequestFailedException)
            {
                return(null);
            }
        }