Covers feature flags for operations: kill switches and safe defaults, percentage and targeted rollouts, Microsoft.FeatureManagement with Azure App Configuration refresh, propagation delay, auditing flag changes, and flag clean-up and expiry.
A feature flag lets you change behaviour without a deploy, which makes it one of the fastest mitigations you have. A kill switch is a long-lived ops flag around a risky dependency or expensive feature: when it misbehaves you turn it off in seconds instead of rolling back. A gradual rollout uses percentage or targeting filters (1% → 10% → 50% → 100%) while you watch error and latency SLOs, so a bad change hurts a few users and is switched off, not rolled back.
In .NET I use Microsoft.FeatureManagement with Azure App Configuration, a refresh interval of about 30 seconds and a safe default if the store is unreachable. Flag changes are audited and annotated on dashboards. The trade-off is flag debt: every flag doubles code paths, so release flags get an owner and an expiry date.
"I separate flags by purpose, because they have different lifetimes. Release flags hide unfinished work and should live for weeks. Experiment flags split traffic for A/B tests. Ops flags, the kill switches, are long-lived on purpose: they wrap things that can hurt the system under stress, like a call to a recommendations service, an expensive report, or a new payment provider, so on-call can switch them off. In an incident, turning a flag off takes seconds and touches nothing else, whereas a rollback redeploys every change since the last release.
In .NET I use Microsoft.FeatureManagement backed by Azure App Configuration. Code asks
IFeatureManager.IsEnabledAsync(\"Recommendations\"), or an endpoint has a[FeatureGate]. For rollouts I use the percentage or targeting filter, so 5% of users or one internal tenant get it first, and I watch the SLO dashboard before stepping up. Two details matter in an incident. First, propagation: with a 30-second refresh interval, a change can take up to that long, plus the next request, to reach every instance, so the runbook says 'wait one minute, then check the metric'. Second, the default: if App Configuration is unreachable at start-up or refresh, the app must fall back to the safe state, which for a kill switch usually means the feature is off. For example, at [company] we [wrapped the product recommendations call in a kill switch]; when [the recommendations service slowed to 8 seconds during a sale], on-call [turned it off and checkout p95 went from 9 s back to 300 ms within a minute], no deploy needed.The mistake I see is never cleaning flags up. Every flag is a branch nobody tests both sides of. The famous case is Knight Capital in 2012, where a reused flag activated old dead code on one server and lost about 440 million US dollars in 45 minutes. So release flags get an owner, an expiry date and a removal ticket, and only ops flags are allowed to be permanent."
| Kind | Purpose | Lifetime | Who changes it |
|---|---|---|---|
| Release | Ship dark, turn on when ready | Days to weeks | Team |
| Experiment | A/B test, measure impact | Weeks | Product |
| Ops / kill switch | Turn off a risky path under stress | Permanent | On-call |
| Permission | Feature for a plan or tenant | Long-lived | Product / config |
| Mitigation | Speed | Scope | When it fits |
|---|---|---|---|
| Turn off a flag | Seconds to a minute | One feature | The bad behaviour is behind a flag |
| Roll back the deployment | Minutes | Everything in the release | Bad code with no flag |
| Scale out | Minutes | Capacity only | Load, not a bug |
| Fail over region | Minutes to hours | Whole service | Regional outage |
| Property | Why |
|---|---|
| Wraps the call, not the UI only | The load must actually stop |
| Has a working fallback (cached, empty, degraded) | Off must not mean broken |
| Safe default when the store is down | A config outage shouldn't enable risk |
| Named in the runbook with propagation time | On-call knows it exists and how long to wait |
| Tested in both states | The off path rots otherwise |
During a sale, the recommendations API's p95 rose to 8 seconds and checkout p95 followed to 9 seconds. On-call turned off the Recommendations kill switch in App Configuration; within about 40 seconds all 12 instances had refreshed, checkout p95 was back to 300 ms, and the page showed popular products from a cached list instead.
Checks the candidate sees feature flags as an operational mitigation with real failure modes, not just a release convenience.
Green flags
Red flags
request ─► IFeatureManager.IsEnabledAsync("Recommendations")
│
▼
IConfiguration "feature_management" section ◄── App Configuration provider (cached)
│ ▲
filters? ── none ─► enabled / disabled │ refresh every N s,
│ │ triggered by requests
▼ │ (UseAzureAppConfiguration)
Percentage / TimeWindow / Targeting filter ─► bool or variant
Microsoft.FeatureManagement reads flags from IConfiguration, so any configuration provider works. The Azure App Configuration provider caches values; the UseAzureAppConfiguration() middleware triggers a refresh in the background when a request arrives after the refresh interval has passed (in worker services you call IConfigurationRefresher.TryRefreshAsync yourself). Propagation delay is therefore refresh interval + time until the next request, per instance.
ITargetingContextAccessor.IFeatureFilter, e.g. by tenant or region.Version 4 of the library added variants through IVariantFeatureManager: a flag returns a named value (e.g. a timeout or an algorithm choice), useful for experiments and gradual configuration changes.
During a rollout or an incident you need to know which requests ran with the flag on. Two ways:
activity?.SetTag("feature.recommendations", enabled)), so dashboards can split error ratio and latency by cohort;"telemetry": { "enabled": true } on the flag) and publish evaluation events to Application Insights, which App Configuration can then show per flag.Without this, "did the new path cause the errors?" becomes guesswork.
| Failure | Effect | Defence |
|---|---|---|
| App Configuration unreachable at start-up | App fails to start, or starts without flags | optional: true with safe local defaults in appsettings; a start-up timeout |
| Store region outage | Refresh fails everywhere | Geo-replicas of the store (the provider can fail over to replicas automatically) |
| Unreachable at refresh | Last known values stay in memory | Fine; log and alert on repeated refresh failures |
| Someone flips the wrong flag | Sudden behaviour change | Audit log, RBAC, change annotations, two-person rule for sensitive flags |
| Two related flags changed one after the other | Instances briefly see one changed and one not | Change them together: a sentinel key that triggers one refresh, or an App Configuration snapshot |
| A request evaluates the same flag twice and gets different answers | Half a request on the new path | IFeatureManagerSnapshot (scoped) caches results for the request |
| Flag evaluated in a hot loop | Extra allocations | Evaluate once per request |
A percentage rollout is a canary at the feature level. A typical schedule: internal users → 1% → 10% → 50% → 100%, each step held long enough to cover peak traffic and judged against the SLO (error ratio, p95 latency) of the affected endpoints, comparing the flag-on and flag-off cohorts from the telemetry above.
OpenFeature is a CNCF vendor-neutral flag API with providers for many back ends. It's worth considering if you might switch vendors; Microsoft.FeatureManagement is the natural fit for an Azure-centric .NET shop.
created (owner, type, expiry) ─► rolling out ─► 100% on ─► code path removed ─► flag deleted from store
│
└─► rolled back ─► fix ─► roll out again
ops flags: created ─► permanent, tested both ways each quarter, listed in the runbook
Every flag doubles the paths through a piece of code; ten independent flags is 1,024 combinations nobody tests. Controls: an owner and expiry per release flag, a report listing flags past expiry or unchanged for 90 days, removal in the definition of done, deleting the flag from the store only after the code no longer reads it, and never reusing a flag name for new behaviour.
optional: true; check which defaults apply.A kill switch around a slow dependency with a safe fallback, backed by Azure App Configuration with a 30-second refresh.
// Program.cs — packages: Microsoft.FeatureManagement.AspNetCore, Microsoft.Azure.AppConfiguration.AspNetCore, Azure.Identity
using Azure.Identity;
using Microsoft.FeatureManagement;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddAzureAppConfiguration(options =>
{
options.Connect(new Uri(builder.Configuration["AppConfig:Endpoint"]!), new DefaultAzureCredential())
.UseFeatureFlags(ff => ff.SetRefreshInterval(TimeSpan.FromSeconds(30))); // propagation budget for the runbook
}, optional: true); // store down at start-up => fall back to appsettings.json defaults below
builder.Services.AddAzureAppConfiguration();
builder.Services.AddFeatureManagement();
builder.Services.AddHttpClient<RecommendationsClient>(c => c.BaseAddress = new Uri("https://recs.internal/"));
var app = builder.Build();
app.UseAzureAppConfiguration(); // triggers refresh on requests after the interval
app.MapGet("/products/{id}/page", async (string id, RecommendationsClient recs, CancellationToken ct) =>
Results.Ok(new ProductPage(id, await recs.GetAsync(id, ct))));
app.Run();
public static class Flags
{
public const string Recommendations = "Recommendations"; // ops flag: permanent, owned by on-call, listed in the runbook
}
public sealed record ProductPage(string ProductId, IReadOnlyList<string> Recommended);
public sealed class RecommendationsClient(HttpClient http, IFeatureManager features, ILogger<RecommendationsClient> logger)
{
private static readonly IReadOnlyList<string> Popular = ["sku-100", "sku-200", "sku-300"]; // degraded but useful fallback
public async Task<IReadOnlyList<string>> GetAsync(string productId, CancellationToken ct)
{
if (!await features.IsEnabledAsync(Flags.Recommendations))
return Popular; // kill switch off: no call at all, so the load on recs actually stops
try
{
return await http.GetFromJsonAsync<List<string>>($"recommendations/{productId}", ct) ?? Popular;
}
catch (Exception ex) when (ex is HttpRequestException or TaskCanceledException)
{
logger.LogWarning(ex, "Recommendations failed for {ProductId}; serving fallback", productId);
return Popular;
}
}
}
// appsettings.json: the safe defaults used when App Configuration is unreachable at start-up
{
"feature_management": {
"feature_flags": [
{ "id": "Recommendations", "enabled": false }
]
}
}
optional: true.Senior engineers design kill switches before the incident: every new external dependency or expensive feature gets the question "what do we turn off if this hurts us, and what does the user see then?" The answer goes into the code, the runbook and the dashboard. A flag nobody on call knows about is not a mitigation.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| Microsoft.FeatureManagement + App Configuration | Azure-hosted .NET, moderate targeting needs | Low; config store cost | Complex experimentation analytics |
| Commercial flag platform (via OpenFeature) | Many teams, experiments, streaming updates | Licence cost, vendor | Small team with simple flags |
| Config value in appsettings + redeploy | Rare changes | Free | Incident mitigation (too slow) |
| Rollback | No flag exists | Minutes, all changes revert | When a flag can isolate the fault |
I measure flag hygiene like any debt: number of flags past expiry, flags with no owner, and how many incidents were mitigated by a flag versus a rollback.
Every minute of an outage costs customers, revenue and trust — for a busy checkout that can be thousands of dollars a minute — while the root cause can be found later from preserved telemetry. So responders ask "what changed?" and reach for the fastest, safest, reversible lever: roll back the release (an App Service slot swap or a previous container image), turn off the feature flag, scale out if it's genuinely capacity, fail over to Australia Southeast if a region is impaired, or shed load with rate limiting to protect the critical path.
Good mitigation is rehearsed (a rollback you've never practised is a new risk), done one change at a time and verified against the SLIs. The trade-off is speed versus evidence: grab the evidence first when it costs seconds (a memory dump, a log export, a note of the deploy id), because a restart or rollback can destroy what explains the cause — but never delay mitigation by minutes to do it.
I'd inventory and classify every setting first: secrets, environment-specific values, shared values, and which must change live. Secrets go to Key Vault. Non-secret settings and feature flags go to Azure App Configuration with a label per environment, and secrets are referenced from there through Key Vault references. The app authenticates with its managed identity using least-privilege roles, and where possible secrets disappear entirely through passwordless Entra ID auth to SQL, Storage and Service Bus.
For refresh, use a sentinel key with a refresh interval and a secret refresh interval, and read live values through IOptionsMonitor. Rotation uses overlapping versions, so old and new both work during the window. Add start-up timeouts and replicas, and keep ValidateOnStart.
The trade-off: central, audited, rotatable configuration, in exchange for a network dependency at start-up that you must design for.
Treat each step as a controlled experiment. Before starting, agree the promotion and rollback criteria: the SLIs for the affected endpoints (error ratio, p95 latency, one business metric such as checkout conversion), the thresholds and the minimum sample size. Use a targeting filter (hashed user id) so users stay in their cohort, and tag telemetry with the flag variant (an Application Insights custom dimension or OpenTelemetry attribute) so a KQL query or dashboard compares the new cohort against the control cohort in the same time window. Step 1% → 10% → 50% → 100%, holding each step through a peak period. If the treatment cohort is worse beyond the threshold, turn the flag off, automatically from an alert or by runbook. The trade-off: small steps are safe but need longer holds to gather enough traffic to be significant.
How to tell it (STAR)
**S:** At [company], during a [big sale], checkout slowed from [300 ms] to [9 seconds] because a recommendations call on the product page was taking [8 seconds]. **T:** As [on-call / the senior on the team] I needed to stop the damage fast without a risky deployment at peak. **A:** The dashboard showed only that dependency had changed, and our runbook listed a kill switch for it, so I turned the flag off in App Configuration, waited the documented 30 seconds, and watched p95 fall back as instances refreshed. Afterwards I [pushed for / added] a timeout and circuit breaker on the call and made kill switches with fallbacks a requirement for new synchronous dependencies. **R:** Customer impact lasted [about 6 minutes] instead of the [30-plus] a rollback and redeploy would have taken, and we re-enabled recommendations safely with a 10% rollout [two days] later.
Last updated 23 Nov 2026.