VikJon.AzureKeyVaultProvider
1.0.5
dotnet add package VikJon.AzureKeyVaultProvider --version 1.0.5
NuGet\Install-Package VikJon.AzureKeyVaultProvider -Version 1.0.5
<PackageReference Include="VikJon.AzureKeyVaultProvider" Version="1.0.5" />
paket add VikJon.AzureKeyVaultProvider --version 1.0.5
#r "nuget: VikJon.AzureKeyVaultProvider, 1.0.5"
// Install VikJon.AzureKeyVaultProvider as a Cake Addin
#addin nuget:?package=VikJon.AzureKeyVaultProvider&version=1.0.5
// Install VikJon.AzureKeyVaultProvider as a Cake Tool
#tool nuget:?package=VikJon.AzureKeyVaultProvider&version=1.0.5
AzureKeyVaultConfigProvider
This nuget package is an alternative to Azure Key Vault References that provides the following benefits:
The one major downside when it comes to key vault references is that you have to know the
secretVersion
(GUID) of the secret you're referencing. This becomes a problem when the development teams don't have access to the key vaults in the production environment. This nuget package removes the need to include the secret version when referencing a key vault secret. Using this package makes it possible to declare key vault references looking like this:@AzureKeyVault(mysecret, https://myvault.vault.azure.net/)
With this package you won't have to repeat the base url of the key vault to be used. All you have to do is to declare the configuration parameter
AZURE_KEY_VAULT_URL
once, looking something like this:
// appsettings.json
{
"AZURE_KEY_VAULT_URL": "https://myvault.vault.azure.net/",
"SENDGRID_API_KEY": "@AzureKeyVault(SendgridApiKey)",
}
Isn't that nice and clean looking? Having to repeat the key vault url is of course no major problem. But it becomes tidious to manage when having a lot of secrets and the url to the vault changes.
Setup
After that you've installed the package using nuget you have to invoke the extension method VikJon.AzureKeyVaultConfigProvider.AddAzureKeyVaultWithNameRefSupport
on the ConfigurationBuilder of your .netcore app. This usually looks something like this in Program.cs
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using VikJon.AzureKeyVaultConfigProvider;
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
config
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile($"appsettings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.AddCommandLine(args)
.AddAzureKeyVaultWithNameRefSupport()
})
.UseStartup<Startup>();
}
Notice! You should not invoke config.AddAzureKeyVault
on the ConfigurationBuilder
Now you can start referencing key vault secrets using the following syntax @AzureKeyVault([SECRET_NAME], [KEY_VAULT_URL:optional])
// appsettings.json
{
"AZURE_KEY_VAULT_URL": "https://myvault.vault.azure.net/",
"SENDGRID_API_KEY": "@AzureKeyVault(SendgridApiKey)"
}
You have the option to provide the base url of your key vault instance on every call to @AzureKeyVault(...) or you can add a single configuration parameter named AZURE_KEY_VAULT_URL
, containing the base url.
Authentication
This package takes for granted that you're using Managed Identites to authenticate against the key vault. If that is not the case you need to implement VikJon.AzureKeyVaultConfigProvider.IKeyVaultGateway and provide the extension method AddAzureKeyVaultWithNameRefSupport
with an instance of that implementation.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.2 is compatible. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 2.2
- Microsoft.Azure.KeyVault (>= 3.0.4)
- Microsoft.Azure.Services.AppAuthentication (>= 1.3.1)
- Microsoft.Extensions.Configuration (>= 2.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|