JDetmar / NLog.Extensions.AzureStorage

NLog Target for Azure Storage. Uses NLog batch write to optimize writes to Storage.
MIT License
31 stars 19 forks source link

Extracting values from Microsoft Azure Key Vault #117

Closed snakefoot closed 1 year ago

snakefoot commented 2 years ago

@JDetmar Would it make sense to have NLog-package that can render values extracted from Azure.Security.KeyVault.Secret ?

Could be like ${keyvaultsecret:item=mysecret} (Similar to ${configsetting} or ${appsetting})

snakefoot commented 2 years ago

Or would it just be overlapping with ${configsetting}:

            if (context.HostingEnvironment.IsProduction())
            {
                var builtConfig = config.Build();
                var secretClient = new SecretClient(
                    new Uri($"https://{builtConfig["KeyVaultName"]}.vault.azure.net/"),
                    new DefaultAzureCredential());
                var vaultOptions = new AzureKeyVaultConfigurationOptions() {
                    ReloadInterval = TimeSpan.FromSeconds(1000)
                }
                config.AddAzureKeyVault(secretClient, new KeyVaultSecretManager(), vaultOptions);
            }

See also: https://docs.microsoft.com/en-us/aspnet/core/security/key-vault-configuration?view=aspnetcore-6.0 and https://www.nuget.org/packages/Azure.Extensions.AspNetCore.Configuration.Secrets

JDetmar commented 2 years ago

That's interesting, I hadn't seen SecretClient