HoneyDrunk.Vault.Providers.AzureKeyVault 0.7.0

dotnet add package HoneyDrunk.Vault.Providers.AzureKeyVault --version 0.7.0
                    
NuGet\Install-Package HoneyDrunk.Vault.Providers.AzureKeyVault -Version 0.7.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HoneyDrunk.Vault.Providers.AzureKeyVault" Version="0.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HoneyDrunk.Vault.Providers.AzureKeyVault" Version="0.7.0" />
                    
Directory.Packages.props
<PackageReference Include="HoneyDrunk.Vault.Providers.AzureKeyVault" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add HoneyDrunk.Vault.Providers.AzureKeyVault --version 0.7.0
                    
#r "nuget: HoneyDrunk.Vault.Providers.AzureKeyVault, 0.7.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package HoneyDrunk.Vault.Providers.AzureKeyVault@0.7.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=HoneyDrunk.Vault.Providers.AzureKeyVault&version=0.7.0
                    
Install as a Cake Addin
#tool nuget:?package=HoneyDrunk.Vault.Providers.AzureKeyVault&version=0.7.0
                    
Install as a Cake Tool

HoneyDrunk.Vault.Providers.AzureKeyVault

Azure Key Vault provider for HoneyDrunk.Vault. Recommended for Azure hosted applications.

Overview

This provider integrates HoneyDrunk.Vault with Azure Key Vault, giving you secure, versioned secret retrieval through the standard Vault abstractions (ISecretStore, SecretIdentifier, SecretValue). It is the preferred provider for applications running in Azure App Service, Azure Container Apps, AKS or any Azure VM with Managed Identity enabled.

Features:

  • Managed Identity authentication (best practice for production)
  • Optional Service Principal authentication for local development
  • Versioned secret retrieval
  • Azure RBAC and access policy support
  • Integration with Vault caching, resilience and telemetry
  • Zero secret values ever logged or emitted in telemetry

Installation

dotnet add package HoneyDrunk.Vault.Providers.AzureKeyVault

Prerequisites

  • Azure subscription
  • Azure Key Vault instance
  • One of:
    • Managed Identity enabled on your application (recommended)
    • Service Principal with secret read permissions

Quick Start

using HoneyDrunk.Vault.Providers.AzureKeyVault.Extensions;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddVaultWithAzureKeyVault(options =>
{
    options.VaultUri = new Uri("https://my-vault.vault.azure.net/");
    options.UseManagedIdentity = true;
});

var app = builder.Build();

Using Service Principal (Local Dev or Non-Azure Hosts)

builder.Services.AddVaultWithAzureKeyVault(options =>
{
    options.VaultUri = new Uri("https://my-vault.vault.azure.net/");
    options.TenantId = builder.Configuration["AzureAd:TenantId"];
    options.ClientId = builder.Configuration["AzureAd:ClientId"];
    // ClientSecret should come from secure config, not source code
    options.UseManagedIdentity = false;
});

Configuration Options

public sealed class AzureKeyVaultOptions
{
    public Uri? VaultUri { get; set; }
    public bool UseManagedIdentity { get; set; } = true;
    public string? TenantId { get; set; }
    public string? ClientId { get; set; }
    public string? ClientSecret { get; set; }
}

If UseManagedIdentity = true, Vault uses DefaultAzureCredential and falls back through the Azure identity chain (Managed Identity, Azure CLI login, Visual Studio login, etc).

Setup Instructions

1. Create Secrets in Key Vault

az keyvault secret set \
  --vault-name my-vault \
  --name db-connection-string \
  --value "Server=..."

Later updates automatically create new versions.

2. Grant Access to Your Application

# For Managed Identity
az keyvault set-policy \
  --name my-vault \
  --object-id <identity-object-id> \
  --secret-permissions get list

# For Service Principal
az keyvault set-policy \
  --name my-vault \
  --spn <client-id> \
  --secret-permissions get list

For secret-only access, certificate and key permissions are not required.

Usage Examples

Get the Latest Version of a Secret

var secret = await secretStore.GetSecretAsync(
    new SecretIdentifier("db-connection-string"),
    ct);

Console.WriteLine(secret.Value.Length);

Azure Key Vault returns the latest version when no version is specified.

Get a Specific Version

var secret = await secretStore.GetSecretAsync(
    new SecretIdentifier("api-key", "3f92c96c7d9e4f1e9a5e2bb0a1b7e3a1"),
    ct);

List Versions

var versions = await secretStore.ListSecretVersionsAsync("api-key", ct);

foreach (var version in versions)
{
    Console.WriteLine($"Version: {version.Version}, Created: {version.CreatedOn}");
}

Gracefully Handle Missing Secrets

var result = await secretStore.TryGetSecretAsync(
    new SecretIdentifier("optional-secret"),
    ct);

if (result.IsSuccess)
    Console.WriteLine("Secret available");
else
    Console.WriteLine($"Not available: {result.ErrorMessage}");

Access Control

Managed Identity

az keyvault set-policy \
  --name my-vault \
  --object-id <identity-object-id> \
  --secret-permissions get list

Service Principal

az keyvault set-policy \
  --name my-vault \
  --spn <client-id> \
  --secret-permissions get list

For secret-only access, certificate and key permissions are not required.

Configuration Example

{
  "Vault": {
    "AzureKeyVault": {
      "VaultUri": "https://my-vault.vault.azure.net/",
      "UseManagedIdentity": true
    }
  }
}

You can bind this in AddVaultWithAzureKeyVault.

Best Practices

  1. Prefer Managed Identity for production
  2. Enable Soft Delete and Purge Protection on your vault
  3. Use secret versions intentionally for rollback
  4. Do not log secret values, only names
  5. Enable Vault caching to reduce Key Vault API usage
  6. Use Private Endpoints for secure and high performance networking
  7. Grant least privilege access (only get and list for secrets)

Troubleshooting

Authentication Issues

MsalServiceException: AADSTS700016: Application not found
  • Verify TenantId, ClientId and ClientSecret if using a Service Principal
  • Ensure Managed Identity is enabled if using MI
  • Check Key Vault firewall or private endpoint settings

Permission Denied

KeyVaultErrorException: Access denied
  • Ensure get and list permissions are granted for secrets
  • Verify the identity object ID used in set-policy

Timeouts or Rate Limiting

  • Ensure Vault caching is enabled
  • Prefer Private Endpoints for low latency
  • Avoid repeatedly fetching the same secret in a hot path

License

MIT License

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on HoneyDrunk.Vault.Providers.AzureKeyVault:

Package Downloads
HoneyDrunk.Data

Provider-neutral persistence orchestration layer for HoneyDrunk.OS Grid. Complete architecture overhaul with Kernel integration for tenant resolution, correlation tracking, and telemetry enrichment. Does not depend on any specific database provider.

HoneyDrunk.Auth

Authentication and authorization library for .NET. Provides JWT Bearer token validation, policy-based authorization, Vault-backed signing key management, and integration with HoneyDrunk.Kernel for Grid-aware context propagation.

HoneyDrunk.Data.Migrations

Migration tooling for HoneyDrunk.Data. Complete architecture overhaul with design-time DbContext factories and migration runner helpers for CI/CD scenarios. Not intended for runtime use.

HoneyDrunk.Web.Rest.AspNetCore

ASP.NET Core integration for HoneyDrunk REST conventions. Provides middleware for correlation propagation, exception mapping, and request logging. Includes MVC filters for model validation, minimal API endpoint conventions, and JSON serialization defaults. Ensures consistent API responses across all services.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.7.0 489 5/27/2026
0.6.0 92 5/26/2026
0.5.0 889 5/18/2026
0.4.0 103 5/4/2026
0.3.0 877 4/25/2026
0.2.0 127 1/25/2026
0.1.0 481 12/8/2025

v0.7.0: AzureKeyVaultSecretStore drops the redundant TryGetSecretAsync / FetchSecretAsync / TryFetchSecretAsync / ListVersionsAsync overrides now that ISecretStore / ISecretProvider supply them as default interface methods (breaking — see HoneyDrunk.Vault 0.7.0 notes). First test coverage added for AzureKeyVaultConfigSource. See CHANGELOG.md for details.