December 23 2025
{
"FeatureManagement": {
"BetaFeature": true
}
}
dotnet add package Microsoft.FeatureManagement.AspNetCore
dotnet add package Microsoft.Azure.AppConfiguration.AspNetCore
{
"AzureAppConfig": {
"ConnectionString": "<YOUR_CONNECTION_STRING>"
}
}
using Microsoft.FeatureManagement;
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
var builder = WebApplication.CreateBuilder(args);
// 1. Connect to Azure App Configuration
builder.Host.ConfigureAppConfiguration(config =>
{
var settings = config.Build();
config.AddAzureAppConfiguration(options =>
{
options
.Connect(settings["AzureAppConfig:ConnectionString"])
// Register feature flags
.UseFeatureFlags(featureOptions =>
{
featureOptions.CacheExpirationInterval =
TimeSpan.FromSeconds(10);
})
// Register refresh with a sentinel key
.ConfigureRefresh(refresh =>
{
refresh
.Register("FeatureFlags:Sentinel", true)
.SetCacheExpiration(
TimeSpan.FromSeconds(10));
});
});
});
// 2. Add Feature Management
builder.Services.AddFeatureManagement();
// 3. Add Azure App Config refresh middleware
builder.Services.AddAzureAppConfiguration();
var app = builder.Build();
// Enable refresh middleware
app.UseAzureAppConfiguration();
app.MapGet("/", () =>
"Feature Flags Demo is running");
// Feature-gated endpoint
app.MapGet("/beta", async (IFeatureManager featureManager) =>
{
if (await featureManager.IsEnabledAsync("BetaFeature"))
{
return Results.Ok("Beta feature is ENABLED");
}
return Results.Ok("Beta feature is DISABLED");
});
app.Run();
1. Design Patterns that Deliver
This isn’t just another design patterns book. Dive into real-world examples and practical solutions to real problems in real applications.Check out it here.
Go-to resource for understanding the core concepts of design patterns without the overwhelming complexity. In this concise and affordable ebook, I've distilled the essence of design patterns into an easy-to-digest format. It is a Beginner level. Check out it here.
Every Monday morning, I share 1 actionable tip on C#, .NET & Arcitecture topic, that you can use right away.
Join 18,000+ subscribers to improve your .NET Knowledge.
Subscribe to the TheCodeMan.net and be among the 18,000+ subscribers gaining practical tips and resources to enhance your .NET expertise.