A lightweight and flexible .NET library for managing Azure App Configuration across multiple environments with easy CRUD operations, serialization, and environment switching.
License
—
Deps
8
Install Size
—
Vulns
✓ 0
Published
Sep 23, 2025
$ dotnet add package Shaunebu.Azure.AppConfiguration
A flexible library for interacting with Azure App Configuration. Supports CRUD operations, key searches, multiple environments, and file serialization in JSON/XML.
Add the library to your project via NuGet:
dotnet add package Shaunebu.Azure.AppConfiguration
Reference: Azure App Configuration Documentation
Initialize the service with your environment configurations (ConfigurationDto) and optionally set a default environment:
using Shaunebu.Azure.AppConfiguration.Models;
using Shaunebu.Azure.AppConfiguration.Services;
var configurations = new List<ConfigurationDto>()
{
new ConfigurationDto
{
Environment = "DEV",
AzureAppConfigConnectionString = "Endpoint=DEV_URL;Id=...;Secret=...",
JsonFileName = "Config-DEV.json",
XmlFileName = "Config-DEV.xml",
AllJsonFileName = "Config-All.json",
AllXmlFileName = "Config-All.xml"
},
new ConfigurationDto
{
Environment = "PROD",
AzureAppConfigConnectionString = "Endpoint=PROD_URL;Id=...;Secret=...",
JsonFileName = "Config-PROD.json",
XmlFileName = "Config-PROD.xml",
AllJsonFileName = "Config-All.json",
AllXmlFileName = "Config-All.xml"
}
};
// Initialize service
AppConfigurationService.Instance.Initialize(configurations, defaultEnvironment: "DEV");
| Property | Type | Description |
|---|---|---|
CurrentEnvironment | string | Default environment used if environment parameter is not passed |
_environments | Dictionary<string, ConfigurationDto> | Stores all initialized environments for the service |
| Method | Description | Default Behavior |
|---|---|---|
GetAllConfigurationByEnvironment() | Get all settings for a single environment | Uses CurrentEnvironment |
GetAllConfigurations() | Get all settings from all environments | Loops through _environments.Values |
var devConfigs = AppConfigurationService.Instance.GetAllConfigurationByEnvironment();
var allConfigs = AppConfigurationService.Instance.GetAllConfigurations();
| Method | Description |
|---|---|
SearchKeyByEnvironment(string key) | Search for a key in a specific environment |
SearchKeyOnAllEnvironments(string key) | Search for a key across all initialized environments |
var featureToggle = AppConfigurationService.Instance.SearchKeyOnAllEnvironments("FeatureToggle");
// Single key in CurrentEnvironment
AppConfigurationService.Instance.AddConfiguration("FeatureXEnabled", "true", "Features");
// Single key in PROD
AppConfigurationService.Instance.AddConfiguration("FeatureXEnabled", "true", "Features", environment: "PROD");
// Multiple keys
var keyValues = new Dictionary<string, object>
{
{ "Key1", "Value1" },
{ "Key2", "Value2" }
};
AppConfigurationService.Instance.AddConfigurations("MyLabel", keyValues, environment: "DEV");
AppConfigurationService.Instance.UpdateConfiguration("FeatureXEnabled", "false", "Features");
AppConfigurationService.Instance.UpdateConfigurations("MyLabel", keyValues, environment: "PROD");
// Single key
AppConfigurationService.Instance.DeleteConfiguration("FeatureXEnabled", "Features");
// Multiple keys
AppConfigurationService.Instance.DeleteConfigurations("MyLabel", keyValues);
// Delete a section
AppConfigurationService.Instance.DeleteEntireConfigurationSection("Features", "FeatureX", environment: "PROD");
Both GetAllConfigurationByEnvironment and GetAllConfigurations support JSON and XML output, optionally saving to disk:
var serialized = AppConfigurationService.Instance.GetAllConfigurationByEnvironment(
saveFile: true,
label: "MyLabel",
serialization: SerializationTypes.Json
);
| Option | Output |
|---|---|
SerializationTypes.Json | .json file |
SerializationTypes.Xml | .xml file |
File paths are configured per ConfigurationDto.
| Feature | Shaunebu.Azure.AppConfiguration 🌐 | Azure SDK Official ⚡ |
|---|---|---|
| Multiple environments support | ✅ Dynamically manage multiple environments via ConfigurationDto | ❌ Requires manual connection string management |
| CRUD operations | ✅ Add, Update, Delete, Get, Search, Delete Section | ✅ Basic CRUD |
| Key search across environments | ✅ SearchKeyOnAllEnvironments() | ❌ Must loop manually |
| Section deletion | ✅ DeleteEntireConfigurationSection() | ❌ Not provided natively |
| Serialization to files | ✅ JSON & XML | ❌ No built-in support |
| Lazy Singleton instance | ✅ AppConfigurationService.Instance | ❌ Must instantiate manually |
| Default/current environment | ✅ CurrentEnvironment property | ❌ No built-in default tracking |
| Multi-label queries | ✅ Supports label filtering easily | ✅ Supported but requires manual coding |
| File saving | ✅ Automatic saving to configured paths | ❌ Manual file operations needed |
| Decoupled from enums | ✅ Fully string-based environment keys | ❌ May require custom enums or constants |
Tip: Shaunebu.Azure.AppConfiguration is designed for multi-environment enterprise scenarios and simplifies working with Azure App Configuration without writing repetitive boilerplate code.
// Initialize
AppConfigurationService.Instance.Initialize(configurations, "DEV");
// Get all settings for default environment
var devConfigs = AppConfigurationService.Instance.GetAllConfigurationByEnvironment();
// Search key across all environments
var keyResults = AppConfigurationService.Instance.SearchKeyOnAllEnvironments("FeatureToggle");
// Add a new key in PROD
AppConfigurationService.Instance.AddConfiguration("FeatureXEnabled", "true", "Features", "PROD");
// Update key in DEV
AppConfigurationService.Instance.UpdateConfiguration("FeatureXEnabled", "false", "Features");
// Delete key in CurrentEnvironment
AppConfigurationService.Instance.DeleteConfiguration("FeatureXEnabled", "Features");
Your library is compatible with multiple platforms thanks to .NET 6+ and the Azure.Data.AppConfiguration SDK:
| Platform | Support | Notes |
|---|---|---|
| 🖥 Windows | ✅ Full | Console, WPF, WinForms, MAUI |
| 🐧 Linux | ✅ Full | Console apps, APIs, microservices |
| 🍏 macOS | ✅ Full | Console apps, MAUI, Blazor |
| 📱 iOS | ✅ Full | MAUI apps, via backend proxy for connection strings |
| 🤖 Android | ✅ Full | MAUI apps, via backend proxy for connection strings |
| 🌐 Blazor Server | ✅ Full | Safe to use with secret keys |
| 🌐 Blazor WebAssembly | ⚠️ Partial | Avoid storing connection strings on client-side; use backend proxy |
| 🌐 ASP.NET / ASP.NET Core | ✅ Full | APIs, web apps, microservices |
Fully decoupled from enums like EnvironmentTypes
Manage multiple environments dynamically
Full CRUD support, including key searches and section deletion
Supports serialization to JSON/XML and saving to disk
Designed for multi-environment enterprise scenarios
References:
Azure App Configuration Official Docs
Azure App Configuration SDK for .NET