Raiqub.AzureKeyVaultReference
2.2.140
Prefix Reserved
dotnet add package Raiqub.AzureKeyVaultReference --version 2.2.140
NuGet\Install-Package Raiqub.AzureKeyVaultReference -Version 2.2.140
<PackageReference Include="Raiqub.AzureKeyVaultReference" Version="2.2.140" />
paket add Raiqub.AzureKeyVaultReference --version 2.2.140
#r "nuget: Raiqub.AzureKeyVaultReference, 2.2.140"
// Install Raiqub.AzureKeyVaultReference as a Cake Addin #addin nuget:?package=Raiqub.AzureKeyVaultReference&version=2.2.140 // Install Raiqub.AzureKeyVaultReference as a Cake Tool #tool nuget:?package=Raiqub.AzureKeyVaultReference&version=2.2.140
Azure Key Vault Reference
The Raiqub Azure Key Vault Reference NuGet packages simplifies the integration of Azure Key Vault with your .NET applications by providing support for Azure Key Vault references in the IConfiguration
system.
🏃 Quickstart | 📗 Guide | 📦 NuGet
<hr />
Features
- Seamless integration of Azure Key Vault references with
IConfiguration
- Easy retrieval of secrets from configuration using Azure Key Vault references
- Support for parsing Azure Key Vault references from strings
NuGet Packages
- Raiqub.AzureKeyVaultReference: provides support for parsing Azure Key Vault references
- Raiqub.AzureKeyVaultReference.Configuration: provides support for integrating Azure Key Vault references with
IConfiguration
Prerequisites
Before you begin, you'll need the following:
- .NET Standard 2.0 or .NET Core 6.0 installed on your machine
- An IDE such as Visual Studio, Visual Studio Code, or JetBrains Rider
Quickstart
To use the library, you can install the desired NuGet package(s) in your Web project and add the configuration provider. Here's an example of how to add the configuration provider:
var builder = Host.CreateDefaultBuilder(args);
builder.ConfigureAzureKeyVaultReference();
or using WebApplication
var builder = WebApplication.CreateBuilder(args);
builder.Host.ConfigureAzureKeyVaultReference();
Guide
To use the Azure Key Vault Configuration Provider, follow these steps:
- Set up Azure Key Vault: Ensure you have an Azure Key Vault instance created and the necessary permissions to access it.
- Install and configure the package: Install the NuGet package and add the necessary configuration to your application.
- Configure Azure Key Vault references: In your `appsettings.json` file or any other configuration source, add Azure Key Vault references using the `@Microsoft.KeyVault` syntax. For example:
{
"MySecret": "@Microsoft.KeyVault(SecretUri=https://your-keyvault.vault.azure.net/secrets/MySecret)",
"OtherSecret": "@Microsoft.KeyVault(VaultName=your-keyvault;SecretName=OtherSecret)"
}
- Retrieve configuration values: Access the configuration values as usual using the `IConfiguration` interface. The Azure Key Vault Configuration Provider will automatically fetch the secrets from Azure Key Vault and replace the references with the corresponding values.
using System.IO;
using Microsoft.Extensions.Configuration;
using Raiqub.AzureKeyVaultReference.Configuration;
var configuration = new ConfigurationManager()
.AddAzureKeyVaultReference(builder =>
builder
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json"))
.Build();
var mySecretValue = configuration["MySecret"];
Parsing Azure Key Vault references
If you need to parse Azure Key Vault references from strings programmatically, you can use the `KeyVaultSecretReference` class provided by this package.
using Raiqub.AzureKeyVaultReference;
var reference = "@Microsoft.KeyVault(SecretUri=https://your-keyvault.vault.azure.net/secrets/MySecret)";
var parsedReference = KeyVaultSecretReference.Parse(reference);
// parsedReference.VaultUri: "https://your-keyvault.vault.azure.net"
// parsedReference.Name: "MySecret"
// parsedReference.Version: null
Default Azure Key Vault
This library supports defining a default Key Vault to use when one is not defined on Azure Key Vault reference.
var builder = Host.CreateDefaultBuilder(args);
builder.ConfigureAzureKeyVaultReference(
options => options.GetDefaultVaultNameOrUri = () => Environment.GetEnvironmentVariable("KEYVAULTURI"));
or using WebApplication
builder.Host.ConfigureAzureKeyVaultReference(
options => options.GetDefaultVaultNameOrUri = () => Environment.GetEnvironmentVariable("KEYVAULTNAME"));
Doing so the Azure Key Vault reference do not need to specify the Key Vault Name
{
"MySecret": "@Microsoft.KeyVault(SecretName=MySecret)"
}
Contributing
If something is not working for you or if you think that the source file should change, feel free to create an issue or Pull Request. I will be happy to discuss and potentially integrate your ideas!
License
This library is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Azure.Identity (>= 1.13.1)
- Azure.Security.KeyVault.Secrets (>= 4.7.0)
- IndexRange (>= 1.0.3)
-
net6.0
- Azure.Identity (>= 1.13.1)
- Azure.Security.KeyVault.Secrets (>= 4.7.0)
-
net8.0
- Azure.Identity (>= 1.13.1)
- Azure.Security.KeyVault.Secrets (>= 4.7.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Raiqub.AzureKeyVaultReference:
Package | Downloads |
---|---|
Raiqub.AzureKeyVaultReference.Configuration
Provides support for integrating Azure Key Vault references with IConfiguration. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.2.140 | 109 | 10/31/2024 |
2.2.136 | 107 | 10/16/2024 |
2.2.125 | 122 | 10/2/2024 |
2.2.100 | 112 | 7/30/2024 |
2.2.86 | 1,419 | 6/24/2024 |
2.2.80 | 154 | 6/18/2024 |
2.2.67 | 158 | 5/19/2024 |
2.2.50 | 601 | 4/24/2024 |
2.2.39 | 176 | 4/6/2024 |
2.2.25 | 163 | 2/25/2024 |
2.2.10 | 984 | 2/4/2024 |
2.2.2 | 156 | 1/29/2024 |
2.1.45 | 348 | 1/7/2024 |
2.1.14 | 287 | 11/2/2023 |
2.1.9 | 151 | 10/31/2023 |
2.1.4 | 1,627 | 8/16/2023 |
2.0.4 | 422 | 8/6/2023 |
1.0.7 | 449 | 6/18/2023 |
1.0.7-g52221d6fec | 162 | 6/18/2023 |
1.0.3-g14999e94ed | 120 | 6/18/2023 |
1.0.1-g679cd8abba | 150 | 6/17/2023 |
See https://github.com/skarllot/azure-keyvault-reference/releases for release notes.