Isaac.

Azure App Configuration: Feature Flags

Manage feature flags dynamically without redeploying applications.

By EMEPublished: February 20, 2025
azureapp configurationfeature flagsfeature managementdeployment

A Simple Analogy

Feature flags are like circuit breakers for features. You can flip switches on/off without changing code, test with real users gradually, and rollback instantly if problems occur.


What Are Feature Flags?

Feature flags are toggles that enable/disable features without code changes. Azure App Configuration manages them centrally for all environments.


Why Use Feature Flags?

  • Gradual rollout: Enable for 10% users, then 50%, then 100%
  • A/B testing: Compare old vs. new features
  • Quick rollback: Disable broken feature instantly
  • No redeployment: Change behavior without deployment
  • Experimentation: Test with real users safely

.NET Implementation

var builder = WebApplication.CreateBuilder(args);

// Load from App Configuration
builder.Configuration.AddAzureAppConfiguration(options =>
{
    options.Connect(builder.Configuration["AppConfig:ConnectionString"])
        .ConfigureFeatureManagement();
});

builder.Services.AddFeatureManagement();

var app = builder.Build();

[ApiController]
[Route("api/[controller]")]
public class OrdersController : ControllerBase
{
    private readonly IFeatureManager _featureManager;
    
    [HttpPost]
    public async Task<IActionResult> CreateOrder(CreateOrderDto dto)
    {
        // Use new checkout if enabled
        if (await _featureManager.IsEnabledAsync("NewCheckout"))
        {
            return await _orderService.CreateOrderAsync(dto);
        }
        
        return await _orderService.CreateOrderLegacyAsync(dto);
    }
}

Practical Example

public class FeatureService
{
    private readonly IFeatureManager _featureManager;
    
    public async Task<OrderResponse> ProcessOrderAsync(Order order)
    {
        // Feature: Enhanced payment validation
        if (await _featureManager.IsEnabledAsync("EnhancedPaymentValidation"))
        {
            await ValidatePaymentAsync(order);
        }
        
        // Feature: Loyalty rewards
        if (await _featureManager.IsEnabledAsync("LoyaltyRewards"))
        {
            await ApplyLoyaltyPointsAsync(order.UserId, order.Total);
        }
        
        return new OrderResponse { Status = "Processed" };
    }
}

Targeting Specific Users

// Target 50% of users
var targetingContext = new TargetingContext
{
    UserId = userId,
    Groups = new List<string> { "beta-testers" }
};

if (await _featureManager.IsEnabledAsync("NewDashboard", targetingContext))
{
    // Show new dashboard
}

Best Practices

  1. Plan rollout: 10% → 25% → 50% → 100%
  2. Monitor metrics: Track feature performance
  3. Clean up flags: Remove old/unused flags
  4. Document flags: Explain purpose and status
  5. Set expiration: Remove flags after period

Related Concepts

  • Canary deployments
  • Blue-green deployments
  • A/B testing frameworks
  • Feature flag management tools (LaunchDarkly)

Summary

Azure App Configuration feature flags enable safe feature deployment without code changes. Use gradual rollout to test with real users and rollback instantly if needed.