Imagile.Framework.Configuration 1.0.12

dotnet add package Imagile.Framework.Configuration --version 1.0.12
                    
NuGet\Install-Package Imagile.Framework.Configuration -Version 1.0.12
                    
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="Imagile.Framework.Configuration" Version="1.0.12" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Imagile.Framework.Configuration" Version="1.0.12" />
                    
Directory.Packages.props
<PackageReference Include="Imagile.Framework.Configuration" />
                    
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 Imagile.Framework.Configuration --version 1.0.12
                    
#r "nuget: Imagile.Framework.Configuration, 1.0.12"
                    
#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 Imagile.Framework.Configuration@1.0.12
                    
#: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=Imagile.Framework.Configuration&version=1.0.12
                    
Install as a Cake Addin
#tool nuget:?package=Imagile.Framework.Configuration&version=1.0.12
                    
Install as a Cake Tool

Imagile.Framework.Configuration

Azure configuration abstractions for .NET applications. Provides seamless integration with Azure Key Vault, automatic credential management for cloud and local development, and comprehensive configuration validation.

Installation

dotnet add package Imagile.Framework.Configuration

Quick Start

using Imagile.Framework.Configuration.Extensions;

var builder = WebApplication.CreateBuilder(args);

// One-line setup: Key Vault + Validation
builder.Services.AddFrameworkConfiguration(builder.Configuration, config => config
    .WithKeyVault(new Uri("https://myvault.vault.azure.net/"))
    .WithValidation());

var app = builder.Build();
app.Run();

Features

AppTokenCredential - Cloud and Local Authentication

Automatically selects the appropriate Azure authentication method based on environment:

Cloud (Azure):

  • WorkloadIdentityCredential (AKS with federated identity)
  • ManagedIdentityCredential (App Service, Container Apps, Functions, VMs)

Local Development:

  • AzureCliCredential (fastest, cross-platform)
  • VisualStudioCredential (Visual Studio account)

No code changes needed when moving between environments.

Key Vault Reference Replacement

Store secrets in Azure Key Vault and reference them in configuration using @KeyVault(SecretName) syntax:

appsettings.json:

{
  "Database": {
    "Host": "localhost",
    "Password": "@KeyVault(DbPassword)"
  },
  "Api": {
    "Key": "@KeyVault(ApiKey)"
  }
}

The framework automatically replaces these references with actual secret values from Key Vault at startup.

Configuration Validation

Validate configuration using data annotations with recursive validation and aggregated error messages:

public class DatabaseSettings
{
    [Required]
    public string Host { get; set; } = string.Empty;

    [Range(1, 65535)]
    public int Port { get; set; }

    [Required]
    public RetrySettings Retry { get; set; } = null!;
}

public class RetrySettings
{
    [Range(0, 10)]
    public int MaxAttempts { get; set; }
}

// Validate configuration
var settings = configuration.Get<DatabaseSettings>()!;
settings.ValidateRecursively(); // Throws ConfigurationValidationException with all errors

Usage Examples

Minimal Setup (Key Vault Only)

builder.Services.AddFrameworkConfiguration(builder.Configuration, config => config
    .WithKeyVault(new Uri("https://myvault.vault.azure.net/")));

Full Setup with User-Assigned Managed Identity

builder.Services.AddFrameworkConfiguration(builder.Configuration, config => config
    .WithKeyVault(
        new Uri("https://myvault.vault.azure.net/"),
        builder.Configuration["AzureManagedIdentityClientId"])
    .WithValidation());

Manual Usage Without Fluent API

// Create credential
var credential = new AppTokenCredential(managedIdentityClientId: null); // null = local dev
builder.Services.AddSingleton<TokenCredential>(credential);

// Create Secret Client
var keyVaultUri = new Uri(builder.Configuration["Azure:KeyVaultUrl"]!);
var secretClient = new SecretClient(keyVaultUri, credential);
builder.Services.AddSingleton(secretClient);

// Replace Key Vault references
builder.Configuration.ReplaceKeyVaultReferences(secretClient);

// Validate configuration
var appSettings = builder.Configuration.Get<AppSettings>()!;
appSettings.ValidateRecursively();

Validation Only (No Key Vault)

builder.Services.AddFrameworkConfiguration(builder.Configuration, config => config
    .WithValidation());

API Reference

ServiceCollectionExtensions

  • AddFrameworkConfiguration(IServiceCollection, IConfiguration, Action<FrameworkConfigurationBuilder>) Primary entry point for configuring Framework Configuration features.

FrameworkConfigurationBuilder

  • WithKeyVault(Uri keyVaultUri, string? managedIdentityClientId = null) Enable Key Vault integration with automatic reference replacement.

  • WithKeyVault(string keyVaultUrl, string? managedIdentityClientId = null) Enable Key Vault integration using string URL.

  • WithValidation() Enable configuration validation using data annotations.

ConfigurationValidationExtensions

  • ValidateRecursively(object obj) Validate an object and its nested properties. Throws ConfigurationValidationException on failure.

  • TryValidateRecursive(object obj, List<ValidationResult> results) Validate without throwing. Returns true if valid, populates results with errors if invalid.

AppTokenCredential

  • AppTokenCredential(string? managedIdentityClientId = null) Create credential for Azure authentication. Automatically selects cloud or local credential chain.

KeyVaultConfigurationExtensions

  • ReplaceKeyVaultReferences(IConfiguration, SecretClient) Replace all @KeyVault(SecretName) references with actual secret values.

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or pull request on GitHub.

Repository

https://github.com/imagile/imagile-framework

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 (1)

Showing the top 1 NuGet packages that depend on Imagile.Framework.Configuration:

Package Downloads
Imagile.Framework.Storage

Azure Storage abstractions for .NET applications. Includes type-safe interfaces for Queue and Blob Storage with convention-based initialization and multi-storage-account support.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.12 31 3/21/2026
1.0.11 30 3/21/2026
1.0.10 37 3/21/2026
1.0.9 35 3/20/2026
1.0.8 95 3/15/2026
1.0.7 93 2/23/2026
1.0.6 121 2/2/2026
1.0.5 152 2/1/2026
1.0.2 101 1/31/2026
1.0.0 115 1/31/2026
0.1.140 105 1/31/2026
0.0.1 104 1/31/2026