AzureKeyVaultEmulator.Client
1.1.0
Trusted SSL is only supported from v2.2.0 or above, please upgrade your package.
See the version list below for details.
dotnet add package AzureKeyVaultEmulator.Client --version 1.1.0
NuGet\Install-Package AzureKeyVaultEmulator.Client -Version 1.1.0
<PackageReference Include="AzureKeyVaultEmulator.Client" Version="1.1.0" />
<PackageVersion Include="AzureKeyVaultEmulator.Client" Version="1.1.0" />
<PackageReference Include="AzureKeyVaultEmulator.Client" />
paket add AzureKeyVaultEmulator.Client --version 1.1.0
#r "nuget: AzureKeyVaultEmulator.Client, 1.1.0"
#addin nuget:?package=AzureKeyVaultEmulator.Client&version=1.1.0
#tool nuget:?package=AzureKeyVaultEmulator.Client&version=1.1.0
Overview
This library simplifies the inclusion of the Azure Key Vault Emulator into your local development environment.
You do not need to use it but it makes life easier. Due to the constraints of Azure Key Vault and the associated client libraries, any requests that don't come from https://*.vault.azure.net
are rejected.
To work around this you need to set DisableChallengeResourceVerification = true
for each client. This library does that for you, emulates the authentication and then dependency injects the clients you need.
Setup
First install the package to your application that needs to use Key Vault:
dotnet add package AzureKeyVaultEmulator.Client
Next you'll need to reference the vaultUri
which points at the docker container.
If you're using .NET Aspire
this will appear in your appsettings.json
:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"myAspireResourceName": "<connectionstring will be populated here>"
}
}
You don't need to add this into your appsettings.json
beforehand, Aspire will do this for you.
If you're simply running the container locally and directly referencing it, you can find the port for https://localhost:{port}
with the following:
docker ps
You'll then need to create a configuration item in your application which allows the dotnet runtime to get the https://localhost:{port}
.
Usage
Including support for the emulator is simple:
// Injected by Aspire using the name "keyvault".
var vaultUri = builder.Configuration.GetConnectionString("keyvault") ?? string.Empty;
// Basic Secrets only implementation
builder.Services.AddAzureKeyVaultEmulator(vaultUri);
You can configure which Clients
you want to expose like so:
builder.Services.AddAzureKeyVaultEmulator(vaultUri, secrets: true, keys: true, certificates: false);
By default only a SecretClient
will be available, but you can easily add CertificateClient
and KeyClient
support.
Access
Now you've got your clients set up you can simply use them like you would any other DI service:
private SecretClient _secretClient;
public SecretsController(SecretClient secretClient)
{
_secretClient = secretClient;
}
public async Task GetSecret(string name)
{
var secret = await _secretClient.GetSecretAsync(name);
}
Quick Tip
To make life easy you can create an environment flag in your Program.cs
to use the Emulator in a dev environment and the hosted Vault in production:
var vaultUri = builder.Configuration.GetConnectionString("keyvault") ?? string.Empty;
if(builder.Environment.IsDevelopment())
builder.Services.AddAzureKeyVaultEmulator(vaultUri, secrets: true, certificates: true, keys: true);
else
builder.Services.AddAzureClients(client =>
{
var asUri = new Uri(vaultUri);
client.AddSecretClient(asUri);
client.AddKeyClient(asUri);
client.AddCertificateClient(asUri);
});
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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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.Core (>= 1.45.0)
- Azure.Security.KeyVault.Certificates (>= 4.7.0)
- Azure.Security.KeyVault.Keys (>= 4.7.0)
- Azure.Security.KeyVault.Secrets (>= 4.7.0)
- Microsoft.AspNetCore (>= 2.3.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.4)
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 | |
---|---|---|---|
2.3.2 | 457 | 5/27/2025 | |
2.3.1 | 174 | 5/24/2025 | |
2.3.0 | 591 | 5/12/2025 | |
2.2.1 | 173 | 5/5/2025 | |
2.2.0 | 145 | 5/4/2025 | |
2.1.0 | 761 | 4/28/2025 | |
2.0.1 | 190 | 4/25/2025 | |
2.0.0 | 247 | 4/22/2025 | |
1.1.0 | 287 | 4/16/2025 | |
1.0.7 | 219 | 4/13/2025 | |
1.0.6 | 228 | 3/27/2025 | |
1.0.5 | 629 | 3/26/2025 | |
1.0.4 | 624 | 3/26/2025 | |
1.0.3 | 633 | 3/26/2025 | |
1.0.2 | 635 | 3/26/2025 |