Deployment strategies for .NET services: rolling, blue-green, canary and App Service slots or Container Apps revisions, their costs, rollback paths and the backward-compatible database changes they require.
Rolling replaces instances in batches: no extra capacity, but old and new versions serve traffic together and rolling back means another rollout. Blue-green runs a full second environment and switches all traffic at once; rollback is switching back. Canary sends a small share of traffic (say 5%) to the new version, compares error rate and latency, then widens or aborts. App Service deployment slots are blue-green in a box: deploy to staging, warm it up, swap, and swap back to roll back.
The catch is the same for all of them: for a while two versions run against one database, so schema changes must be expand/contract and backward compatible. The trade-off is cost and complexity (blue-green and canary) against blast radius and rollback speed.
"All four strategies answer one question: how much of production sees the new version before you're sure it works, and how fast can you get back? Rolling deployment replaces instances a batch at a time; Kubernetes does this by default with
maxSurgeandmaxUnavailable. It needs no extra capacity, but there's no clean cut-over: old and new serve users together, and rollback is just rolling the old image out again, which takes as long as the deploy did.Blue-green keeps two full environments. You deploy to the idle one, test it, then switch the router. Rollback is flipping back, usually in seconds, but you pay for double capacity during the switch. On Azure App Service that's what deployment slots give you: deploy to
staging, letapplicationInitializationwarm it up, then swap. The swap exchanges the slots' routing, so the warm instances take traffic; swapping back is the rollback. Canary is the cautious version: route 5% of requests to the new revision, compare its error rate and p95 latency with the old one, and widen to 25, 50, 100% if it's healthy. Container Apps does that with revision traffic weights; on AKS I'd use Argo Rollouts or Flagger.The mistake I see is thinking a slot swap makes a deployment reversible on its own. It doesn't if the release dropped a column or changed a message contract: the old code you swap back to can't read the new data. So every strategy depends on expand/contract migrations: add first, migrate, switch reads, and only remove in a later release. Rollback is a property of the whole change, not of the deployment tool."
| Rolling | Blue-green | Canary | App Service slots | |
|---|---|---|---|---|
| Extra capacity | Small (surge) | 2× during switch | Small to medium | Slot shares the plan's instances |
| Two versions live at once | Yes, mixed | Briefly, or not at all | Yes, by design | Briefly during swap |
| Blast radius of a bad release | Grows batch by batch | Everyone at switch time | Only the canary share | Everyone at swap |
| Rollback | Redeploy old version (minutes) | Switch back (seconds) | Set canary weight to 0 (seconds) | Swap back (seconds to a minute) |
| Good for | Stateless services on Kubernetes | Big, risky releases | High-traffic services with good metrics | App Service web apps and APIs |
kubectl rollout undo deployment/orders-api or redeploy the previous image tag.production gets the previous build, which is still warm in staging.| Change | Unsafe (breaks old version) | Safe (expand/contract) |
|---|---|---|
| Rename column | sp_rename in one release |
Add new column, dual-write, backfill, switch reads, drop old later |
| Make column NOT NULL | Alter in same release as code | Add with default, backfill, enforce in a later release |
| Remove column | Drop with the code change | Stop using it, deploy, then drop next release |
| Change message contract | Replace fields | Add optional fields; consumers tolerate unknown fields |
An API on App Service Premium v3 moved from deploying straight to production (about 40 seconds of 502s per release while the app restarted) to deploy-to-staging-and-swap with warm-up. Release-time errors dropped to zero, and a bad release in March was rolled back with a swap in 50 seconds instead of a 12-minute redeploy.
Checks whether the candidate understands deployment strategies as blast-radius and rollback trade-offs, and knows that database and contract compatibility decide whether rollback really works.
Green flags
Red flags
Rolling (Kubernetes, maxSurge=1, maxUnavailable=0)
v1 v1 v1 v1 → v1 v1 v1 v1 v2 → v1 v1 v1 v2 → ... → v2 v2 v2 v2
(new pod must pass readiness before an old pod is removed)
Blue-green
┌──► BLUE (v1) ◄── live
router ───┤
└──► GREEN (v2) ◄── deployed, tested, idle
(switch the router; switch back to roll back)
Canary
router ── 95% ──► v1
── 5% ──► v2 ──► compare error rate, p95, business metric
└─► promote 25% → 50% → 100% or abort to 0%
/ or the paths in applicationInitialization, and an optional custom warm-up path via WEBSITE_SWAP_WARMUP_PING_PATH), and only then switches routing. Users never hit a cold instance.ASPNETCORE_ENVIRONMENT=Staging. Everything else travels with the code.az containerapp ingress traffic set --revision-weight orders--v2=10 orders--v1=90. Labels give stable URLs to test a revision before it gets traffic.Even blue-green has a window where both versions exist: background workers, queued messages written by v1 read by v2, sessions started on v1. And after rollback, v1 reads data written by v2. So the real rule is N and N-1 must both work with the current schema and message formats.
Release 1 (expand): add column Email2 (nullable); code writes Email and Email2
Backfill job: copy Email → Email2 in batches
Release 2 (switch): code reads Email2, still writes both
Release 3 (contract): stop writing Email; drop Email column
Each release can be rolled back to the previous one safely.
Good canary analysis compares the canary with the baseline over the same window: HTTP 5xx ratio, p95/p99 latency, dependency failures, and one business metric (orders placed per minute). With Application Insights, tag telemetry with the revision or slot (cloud_RoleInstance, or a custom service.version resource attribute in OpenTelemetry) so you can split charts by version.
staging slot; deploy two versions of a minimal API that returns its version, and swap while running curl in a loop. Count failed requests.kubectl rollout status and kubectl rollout undo on a Deployment.Warm-up and version reporting so slot swaps and canaries can be verified (Program.cs):
using System.Reflection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHealthChecks()
.AddCheck<StartupWarmupCheck>("warmup", tags: ["ready"]);
builder.Services.AddSingleton<StartupWarmupCheck>();
builder.Services.AddHostedService(sp => sp.GetRequiredService<StartupWarmupCheck>());
var app = builder.Build();
var version = Assembly.GetExecutingAssembly()
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "unknown";
// The swap warm-up and the canary analysis can both check which version answered.
app.MapGet("/version", () => Results.Ok(new VersionDto(version, Environment.MachineName)));
app.MapHealthChecks("/health/ready", new() { Predicate = r => r.Tags.Contains("ready") });
app.Run();
public sealed record VersionDto(string Version, string Instance);
// Reports unhealthy until caches are primed, so the swap waits for a warm instance.
public sealed class StartupWarmupCheck : BackgroundService, IHealthCheck
{
private volatile bool _ready;
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken); // e.g. load reference data, JIT hot paths
_ready = true;
}
public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken ct = default) =>
Task.FromResult(_ready ? HealthCheckResult.Healthy() : HealthCheckResult.Unhealthy("Warming up"));
}
# App Service: deploy to staging, swap with a custom warm-up path, swap back to roll back
az webapp config appsettings set -g rg-orders-prod-aue -n app-orders-prod-aue --slot staging \
--settings WEBSITE_SWAP_WARMUP_PING_PATH=/health/ready WEBSITE_SWAP_WARMUP_PING_STATUSES=200
az webapp deploy -g rg-orders-prod-aue -n app-orders-prod-aue --slot staging --src-path app.zip
az webapp deployment slot swap -g rg-orders-prod-aue -n app-orders-prod-aue --slot staging --target-slot production
# rollback = run the same swap again
# Container Apps canary: 10% to the new revision, then promote or abort
az containerapp ingress traffic set -g rg-orders-prod-aue -n orders-api \
--revision-weight orders-api--v42=10 orders-api--v41=90
# Kubernetes rolling update that never drops capacity
apiVersion: apps/v1
kind: Deployment
metadata: { name: orders-api }
spec:
replicas: 4
strategy:
type: RollingUpdate
rollingUpdate: { maxSurge: 1, maxUnavailable: 0 }
selector: { matchLabels: { app: orders-api } }
template:
metadata: { labels: { app: orders-api } }
spec:
containers:
- name: api
image: contosoacr.azurecr.io/orders-api:sha-3f2c1ab
readinessProbe: { httpGet: { path: /health/ready, port: 8080 }, periodSeconds: 5 }
NOT NULL change in the same release as the code that needs it. Why it is wrong: During a rolling update or canary the old version is still serving and starts failing immediately; after a rollback it fails completely. Instead: Split it across releases (add, backfill, switch, drop later) and block destructive migrations in the pipeline unless explicitly approved.staging, warm up, then swap.maxUnavailable: 0.I pick the cheapest strategy that limits blast radius enough for the service's risk, and I invest more in rollback-safety of the change than in the deployment mechanics. Most teams on App Service get 90% of the value from slots plus warm-up; canary pays off only when there's enough traffic for 5% to be statistically meaningful and good telemetry split by version.
None of these strategies work without observability. Before choosing one, I make sure every request and dependency call is tagged with the version (OpenTelemetry service.version, or the slot/revision name in Application Insights), that there are alerts on 5xx ratio and p95 latency per version, and that one business metric (orders per minute) is on the release dashboard. Rollback should be triggered by those signals, ideally automatically, and measured: change failure rate and time to restore (DORA). If rollbacks take longer than 5 minutes or fail because of schema changes, fix the migration practice before buying a fancier rollout tool.
What each strategy really costs
| Strategy | Compute cost | Operational cost | Risk cost |
|---|---|---|---|
| Rolling | +1 surge pod/instance during rollout | Low; built into Kubernetes and App Service scale-out | Mixed versions; slow rollback; whole fleet affected by the end |
| Blue-green | Up to 2× for the rollback window | Two environments to keep in sync, router switch | Everyone exposed at once, but instant switch back |
| Canary | Small extra (a few replicas) | Traffic splitting, per-version telemetry, analysis rules (Argo Rollouts, Flagger) | Smallest blast radius; needs enough traffic to judge |
| App Service slots | No extra instances (slots share the plan), Standard tier+ | Sticky settings, warm-up config | Staging load affects production; workers may run twice |
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| Rolling | Stateless containers on AKS, low-risk changes | Mixed versions, slow rollback | Releases you need to cut over atomically |
| Blue-green | High-risk releases, quick rollback needed | Double capacity during switch | Very large stateful environments |
| Canary | High traffic, good metrics, many deploys a day | Tooling and analysis setup | Low traffic (signal is noise) |
| App Service slots | Web apps and APIs on App Service | Standard tier+, shared instances | Workers that must not run twice (pause them) |
Never use RenameColumn while old and new app versions overlap: the old version would query a column that no longer exists. Use expand and contract over several releases. 1. Expand: add the new column (nullable). 2. Dual write: release an app version that writes both columns in the same SaveChanges (same transaction), or add a trigger that copies writes made by the old version, and still reads the old column. 3. Backfill existing rows in small batches (UPDATE TOP (5000) ... WHERE New IS NULL) to avoid long locks and log growth, then verify with a count of mismatches. 4. Switch reads to the new column; keep writing both so a rollback to the previous version still works. 5. Contract: once no running version uses the old column, stop writing it and drop it in a later migration. Each step is backward compatible with the version before it.
I generate migrations locally with dotnet ef migrations add, then make deployment a separate, reviewed step. The pipeline produces an artefact: either an idempotent SQL script (dotnet ef migrations script --idempotent) for a DBA to review, or a migration bundle (dotnet ef migrations bundle), a self-contained executable that applies pending migrations. That artefact runs once, before the new app version starts, with a dedicated deployment identity. I avoid Database.Migrate() at startup because several instances can race, the app needs DDL permissions it shouldn't have, and a failed migration turns into a crash loop.
How to tell it (STAR)
**S:** We deployed our orders API through staging slots, so everyone assumed we could always swap back. **T:** A release renamed a column, and when we had to roll back for an unrelated bug, I was on call to get orders working again. **A:** I traced the errors in Application Insights to the old code reading a column that no longer existed, added a computed column with the old name as a stop-gap so the previous version worked, then led a change so destructive migrations go through expand/contract and the pipeline blocks drops and renames without a label. **R:** Orders were back within [about 20 minutes], and in the [next 12 months] we had [zero] rollbacks blocked by schema changes.
Last updated 23 Nov 2026.