JT.SmartConfigManager 1.0.10

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

JT.SmartConfigManager

JT.SmartConfigManager is a powerful, unified configuration manager for .NET apps.
It lets you load and merge configurations from multiple sources like:

  • appsettings.json
  • Azure Key Vault
  • Azure App Configuration
  • SQL Server Config Table
  • ✅ Environment Variables

All sources are dynamically merged into a single strongly-typed class — simplifying config access and management.


🚀 Why Use This?

Managing configuration across environments can be painful.
This package solves that by:

  • 🔐 Centralizing secrets from multiple sources
  • 📦 Auto-binding values into a POCO class
  • ⚙️ Supporting validation & auto-reload
  • 🧹 Reducing manual code for loading secrets or DB config

It’s ideal for enterprise, cloud-native, or microservice .NET Core apps.


🔧 Features

  • ✅ Merges JSON, SQL, KeyVault, App Config into one model
  • ✅ Supports secret injection via IVaultInjectable
  • ✅ Clean POCO model binding
  • ✅ Auto reload on interval (optional)
  • ✅ Easily extendable for custom sources

📦 Install via NuGet

dotnet add package JT.SmartConfigManager

📁 Sample appsettings.json

{
  "AppSettings": {
    "AppName": "Demo API",
    "Environment": "Development"
  },
  "SqlConfig": {
    "ConnectionString": "Server=localhost\\SQLEXPRESS01;Database=testDB;Trusted_Connection=True;TrustServerCertificate=True;",
    "Query": "SELECT [Key], [Value] FROM AppConfig"
  },
  "KeyVault": {
    "VaultUri": "https://jt-configmanager.vault.azure.net/"
  },
  "AzureAppConfig": {
    "ConnectionString": "Endpoint=https://jt-config-manager.azconfig.io;Id=...;Secret=..."
  }
}

🧱 POCO Model Example

public class MyAppSettings : IVaultInjectable
{
    public AppSettings? AppSettings { get; set; }
    public SqlConfig? SqlConfig { get; set; }

    public Dictionary<string, string>? VaultSecretsDict { get; set; }

    public List<KeyValuePair<string, string>>? VaultSecrets =>
        VaultSecretsDict?.ToList();

    public List<KeyValuePair<string, string>>? AppConfigList { get; set; }  // Optional for Azure AppConfig
}

public class AppSettings
{
    public string? AppName { get; set; }
    public string? Environment { get; set; }
}

public class SqlConfig
{
    public string ConnectionString { get; set; } = string.Empty;
    public string Query { get; set; } = string.Empty;
}

🛠️ Program.cs Setup

var options = new SmartConfigOptions<MyAppSettings>();

options.Sources.Add(new JsonFileSource("appsettings.json"));

if (!string.IsNullOrWhiteSpace(appSettings.SqlConfig?.ConnectionString))
{
    options.Sources.Add(new SqlConfigSource(
        appSettings.SqlConfig.ConnectionString,
        appSettings.SqlConfig.Query));
}

if (!string.IsNullOrWhiteSpace(appSettings.AzureAppConfig?.ConnectionString))
{
    options.Sources.Add(new AzureAppConfigSource(appSettings.AzureAppConfig.ConnectionString));
}

if (!string.IsNullOrWhiteSpace(baseConfig["KeyVault:VaultUri"]))
{
    options.Sources.Add(new AzureKeyVaultSource<MyAppSettings>(baseConfig["KeyVault:VaultUri"]!));
}

var configManager = new SmartConfigManager<MyAppSettings>(options);
var finalSettings = configManager.Current;

builder.Services.AddSingleton(finalSettings);

🔍 Example /config Output

The /config endpoint will return a clean JSON like this:

{
  "appName": "Demo API",
  "environment": "Development",
  "sqlConn": "Server=localhost\\SQLEXPRESS01;Database=testDB;Trusted_Connection=True;TrustServerCertificate=True;",
  "sqlQuery": "SELECT [Key], [Value] FROM AppConfig",
  "azureAppConfig": [
    {
      "key": "AzureAppConfig:ConnectionString",
      "value": "Endpoint=https://jt-config-manager.azconfig.io;Id=...;Secret=..."
    }
  ],
  "vaultSecrets": [
    {
      "key": "AzureAppConfig:ConnectionString",
      "value": "..."
    },
    {
      "key": "DbKey1",
      "value": "Value from SQL"
    },
    {
      "key": "DbKey2",
      "value": "SQL Loaded Config"
    },
    {
      "key": "jt-vault-v1",
      "value": "topsecret$1"
    },
    {
      "key": "VaultSecret",
      "value": "myValue$1"
    },
    {
      "key": "jt-Key2",
      "value": "Key22"
    },
    {
      "key": "jt-Key1",
      "value": "Key11"
    }
  ]
}

🧪 Demo Project See the live working example in the demo repo: 🔗 JT.SmartConfigManager.Demo

Includes:

✅ SQL table with config values

✅ Azure Key Vault integration

✅ Azure AppConfig integration

✅ /config endpoint for viewing merged settings

✅ Benefits

Cleanly separate secrets and runtime config

Works with Azure Key Vault, App Config, and SQL

Easy to maintain for multi-env deployments

Strong typing and validation built-in

Avoid hardcoding secrets or fragile manual loading

📄 License

This project is licensed under the MIT License.

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

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
1.0.10 146 7/13/2025
1.0.9 70 7/12/2025
1.0.8 140 7/9/2025
1.0.7 138 7/9/2025
1.0.6 141 7/9/2025
1.0.3 149 7/9/2025
1.0.2 208 6/21/2025 1.0.2 is deprecated because it is no longer maintained.