📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

The pipeline says the deployment succeeded, but the new version of your ASP.NET Core API won't start: App Service shows HTTP 500.30, or the Kubernetes pods are in CrashLoopBackOff. How do you find out why quickly, what are the usual causes (configuration, missing secrets or Key Vault access, migrations, a missing dependency, a port or health check mismatch), and how do you make deployments that can't go green while the app is broken?

A production playbook for a deployment that succeeds but whose app fails to start: getting the startup exception from App Service and Kubernetes, the usual causes (configuration, secrets, managed identity, migrations, missing native dependencies, ports and probes), rollback, and making the pipeline verify startup.

Mid-Level Debugging Intermediate azure-app-service ci-cd deployment kubernetes production startup-failure

🎯 Key points

  • Mitigate first: swap the slot back or kubectl rollout undo; the old version is known good
  • Get the startup exception: kubectl logs --previous, kubectl describe pod (exit code, probe failures), App Service log stream or Diagnose and solve problems for 500.30
  • Exit code tells you a lot: 139/134 native crash, 137 OOMKilled or killed by probe, 1/non-zero unhandled exception in Program.cs
  • Configuration: a missing key fails ValidateOnStart, a renamed environment variable, appsettings.{Environment}.json not deployed
  • Secrets: Key Vault reference unresolved because the managed identity lacks Key Vault Secrets User or the network blocks it
  • Migrations run at startup that fail or time out, or a schema the new code expects that isn't there yet
  • Platform mismatches: the .NET 10 images (like every image since .NET 8) listen on 8080 as a non-root user, so old probes on port 80 fail; chiseled images lack ICU or native libraries
  • Prevent: ValidateOnStart, readiness checks that exercise dependencies, slot swap with warm-up or a canary, and a smoke test that gates promotion

⏱ 30-second answer

"Deployed" only means the artefact was copied; starting is a separate step that the pipeline often doesn't check. First I roll back (slot swap back or kubectl rollout undo). Then I get the startup exception: kubectl logs --previous and kubectl describe pod for the exit code and probe failures, or the App Service log stream for a 500.30. The usual causes are configuration (a missing or renamed key), secrets (a Key Vault reference failing because the managed identity lacks access), migrations run at startup, a missing native dependency in a slim image, or a port mismatch with the health probe (official ASP.NET Core images, including .NET 10's, listen on 8080, a change that arrived in .NET 8). The prevention is making startup part of the deployment: ValidateOnStart, readiness probes, slot warm-up or canaries, and a smoke test before promotion.

🗣 Full answer (senior)

How I would answer this in an interview

"When the pipeline is green and the app is down, the pipeline is checking the wrong thing: it checked that files were copied or an image was pushed, not that the process started and served a request. So the first action is to restore service with whatever is fastest: swap the App Service slot back, or kubectl rollout undo. If the rollout used a readiness probe properly, Kubernetes may have kept the old pods serving anyway, which is the best case.

Then I want the actual startup exception, because the cause is almost always one line in it. In Kubernetes, kubectl describe pod shows the last state and exit code, and kubectl logs --previous shows the output of the crashed container. Exit code 1 with a stack trace from Program.cs is an unhandled exception at startup; 137 can be OOM or the kubelet killing it after failed liveness probes; 139 is a native crash. On App Service, a 500.30 means the ASP.NET Core process failed to start; the log stream, or turning on stdout logging, shows the exception, and 'Diagnose and solve problems' has a startup failure detector.

The causes repeat. Configuration: someone renamed a setting and options validation with ValidateOnStart fails, which is good, it failed loudly. Secrets: a Key Vault reference can't resolve because the new slot's managed identity doesn't have the Key Vault Secrets User role, or Key Vault's firewall blocks the new subnet. Migrations: the app runs Database.Migrate() at startup and it fails or times out on a large table. Platform: the .NET 8 and later container images listen on port 8080, and the probe still points at 80, or a chiseled image doesn't include ICU or a native library the app needs. The mistake I see is fixing the config by hand in the portal and moving on. The real fix is making the pipeline unable to go green unless the app starts and passes a smoke test."


The playbook, in order

Step What I do Tool or command
1. Symptom 500.30, 502/503 from the front door, or CrashLoopBackOff App Service, kubectl get pods
2. First five minutes Roll back Slot swap back, kubectl rollout undo deployment/api
3. Data to collect Exit code, startup logs, events kubectl describe pod, kubectl logs --previous, App Service log stream
4. Rule out Code exception vs configuration vs platform (ports, probes, resources) Read the first exception; compare config between slots or releases
5. Root cause The exact missing key, role assignment, migration or dependency Key Vault reference status, migration logs, image contents
6. Fix Correct config through IaC, grant the role, separate migrations, fix the image Pipeline change
7. Prevention ValidateOnStart, readiness probes, warm-up, smoke test gate Pipeline, health checks

Symptom to cause

What you see Likely cause Check
OptionsValidationException at startup Missing or renamed setting Diff app settings between releases or slots
Azure.Identity.CredentialUnavailableException or 403 from Key Vault Managed identity missing, wrong, or lacks role; firewall Key Vault reference status in the portal; role assignments
SqlException in Migrate() Migration failed or timed out at startup Migration logs; run migrations as a separate step
DllNotFoundException or ICU errors Native dependency missing in the image Image base (chiseled, Alpine), InvariantGlobalization
Pods restart with no exception, liveness failing Port or path mismatch, slow startup ASPNETCORE_HTTP_PORTS, probe config, startupProbe
Exit code 137 within seconds Memory limit too low for startup Container limit, startup allocations

Production example

In a typical case, a release moves a connection string into Key Vault and uses a Key Vault reference in App Service. Production's staging slot has a new system-assigned identity that was never granted access, so the reference stays unresolved, the options validation fails and the slot returns 500.30. Because the pipeline swapped without a warm-up check, production was down for 14 minutes until someone swapped back. Adding the role assignment to Bicep and a warm-up path (WEBSITE_SWAP_WARMUP_PING_PATH) pointing at a readiness endpoint means a broken slot can no longer be swapped in.

🔍 What the interviewer is checking

Checks that the candidate can restore service fast, extract the real startup error on App Service and Kubernetes, recognise the common startup breakers, and change the pipeline so a broken release can't go green.

Green flags

  • Rolls back first and knows how on both platforms
  • Uses kubectl logs --previous, describe and exit codes; knows what 500.30 means
  • Names config validation, managed identity and Key Vault roles, migrations, ports and native dependencies
  • Gates releases on readiness, warm-up and smoke tests

Red flags

  • Fixes things by hand in the portal as the solution
  • Runs migrations at startup without seeing the risks
  • Doesn't distinguish liveness from readiness

📚 Learn in depth

1. What "deployed" actually verifies

pipeline ──► build ──► push image / zip ──► update deployment / slot   ← pipeline says green here
                                                   │
                                                   ▼
                         process starts ──► host builds ──► config + secrets load
                                                   │
                         DI validates ──► migrations? ──► Kestrel listens ──► probes pass
                                                                                ← app actually works here

Unless the pipeline waits for the second half (rollout status with readiness probes, slot warm-up, smoke tests), it reports success too early.

2. App Service and 500.30

On Windows App Service with the ASP.NET Core Module (in-process hosting), 500.30 means the app failed to start; 500.31 means the runtime couldn't be found; 502.5 is the older out-of-process equivalent. On Linux App Service you usually see a 503 and container logs. Enable application logging or stdout logging, use the log stream, and use Diagnose and solve problems → Availability and Performance, which surfaces startup exceptions.

Slot swap with warm-up: App Service warms the staging slot before swapping. Set WEBSITE_SWAP_WARMUP_PING_PATH (and optionally WEBSITE_SWAP_WARMUP_PING_STATUSES) so the swap waits for a real readiness endpoint; if the slot can't respond, the swap fails instead of breaking production.

3. Kubernetes: rollout, probes and CrashLoopBackOff

A Deployment with RollingUpdate and maxUnavailable: 0 keeps old pods until new pods are Ready. If new pods never pass readiness, old pods keep serving and kubectl rollout status eventually times out (based on progressDeadlineSeconds), which the pipeline should treat as failure. CrashLoopBackOff means the container keeps exiting and the kubelet backs off restarts exponentially, up to five minutes.

Use a startupProbe for slow starts so liveness doesn't kill the app while it's still initialising.

4. Configuration and secrets

  • services.AddOptions<T>().BindConfiguration(...).ValidateDataAnnotations().ValidateOnStart() fails startup with a clear message instead of failing on the first request.
  • Key Vault references in App Service (@Microsoft.KeyVault(SecretUri=...)) resolve using the app's managed identity. The identity needs the Key Vault Secrets User role (RBAC) or an access policy, and network access if Key Vault has a firewall or private endpoint. Each slot can have its own identity.
  • With AddAzureKeyVault in code, the same identity and network rules apply, and a failure throws during host build.

5. Migrations at startup

Running Database.Migrate() at startup couples deployment to schema changes: with several instances they race, a long migration delays startup past the probe, and a failure leaves the app down. Prefer running migrations as a separate pipeline step (an idempotent script or a migration bundle via dotnet ef migrations bundle) before deploying code, using expand/contract so old and new versions both work against the new schema.

6. Container platform details

  • Since .NET 8, official ASP.NET Core images listen on 8080 by default (ASPNETCORE_HTTP_PORTS=8080) and run as a non-root user. Old manifests that expect port 80 break.
  • Chiseled and Alpine images omit things like ICU; either set InvariantGlobalization or use the -extra variant that includes ICU and tzdata.
  • Native dependencies (System.Drawing.Common on Linux, image libraries) must be in the image.

Try it yourself

  1. Add an options class with [Required] and ValidateOnStart(); remove the setting and run the app to see the startup failure.
  2. Deploy a container that listens on 8080 with a liveness probe on port 80 to a local kind or minikube cluster; watch CrashLoopBackOff and read kubectl describe.
  3. Run kubectl logs <pod> --previous to see the crashed container's output.
  4. Create a migration bundle with dotnet ef migrations bundle and run it as a separate step.
  5. On a test App Service, set WEBSITE_SWAP_WARMUP_PING_PATH to /health/ready and try swapping a slot that fails readiness.

💻 Code

Startup that fails fast and clearly, plus probes the platform can trust.

// Program.cs
using System.ComponentModel.DataAnnotations;
using Microsoft.Extensions.Diagnostics.HealthChecks;

var builder = WebApplication.CreateBuilder(args);

// Fail at startup with a named setting, not on the first request with a NullReferenceException.
builder.Services.AddOptions<PaymentsOptions>()
    .BindConfiguration(PaymentsOptions.Section)
    .ValidateDataAnnotations()
    .ValidateOnStart();

builder.Services.AddHealthChecks()
    .AddCheck("self", () => HealthCheckResult.Healthy(), tags: ["live"])
    .AddSqlServer(builder.Configuration.GetConnectionString("Orders")!, tags: ["ready"]); // AspNetCore.HealthChecks.SqlServer

var app = builder.Build();

app.MapHealthChecks("/health/live", new() { Predicate = r => r.Tags.Contains("live") });   // process is up
app.MapHealthChecks("/health/ready", new() { Predicate = r => r.Tags.Contains("ready") }); // can serve traffic
app.Run();

public sealed class PaymentsOptions
{
    public const string Section = "Payments";
    [Required, Url] public string BaseUrl { get; init; } = "";
    [Required] public string MerchantId { get; init; } = "";
}
# Kubernetes: probes on the port the app actually listens on (.NET 8+ images default to 8080)
containers:
  - name: orders-api
    image: myregistry.azurecr.io/orders-api:1.42.0
    ports: [{ containerPort: 8080 }]
    startupProbe:   { httpGet: { path: /health/live, port: 8080 }, failureThreshold: 30, periodSeconds: 2 }
    livenessProbe:  { httpGet: { path: /health/live, port: 8080 }, periodSeconds: 10, failureThreshold: 3 }
    readinessProbe: { httpGet: { path: /health/ready, port: 8080 }, periodSeconds: 5 }
# Diagnose, then roll back
kubectl get pods -n prod -l app=orders-api
kubectl describe pod orders-api-6c9d -n prod      # Last State, Exit Code, probe failures, events
kubectl logs orders-api-6c9d -n prod --previous   # output of the crashed container
kubectl rollout undo deployment/orders-api -n prod
# In the pipeline: fail the job if the rollout doesn't become ready
kubectl rollout status deployment/orders-api -n prod --timeout=180s

⚠ Common mistakes

  • Mistake: Treating a green pipeline as a working release. Why it is wrong: It usually only verified the copy or image push. Instead: Gate on rollout status, readiness and a smoke test.
  • Mistake: Fixing configuration by hand in the portal. Why it is wrong: The next deployment or a new environment breaks again, and nobody knows what changed. Instead: Fix it in IaC (Bicep or Terraform) and redeploy.
  • Mistake: Reading the logs of the new container, not the crashed one. Why it is wrong: After a restart, kubectl logs shows the fresh attempt, often before it fails. Instead: Use --previous and describe for the exit code.
  • Mistake: Running EF Core migrations at app startup across many instances. Why it is wrong: Instances race, slow migrations fail probes, and a failure takes the app down. Instead: Run migrations as a separate, idempotent pipeline step with expand/contract.
  • Mistake: Forgetting that each App Service slot can have its own managed identity. Why it is wrong: Key Vault references resolve in one slot and fail in the other. Instead: Grant roles to each identity in IaC, or use a user-assigned identity shared deliberately.
  • Mistake: Pointing liveness at a dependency check. Why it is wrong: A slow database restarts every pod. Instead: Liveness checks the process; readiness checks dependencies.
  • Mistake: Upgrading base images without checking the port and user changes. Why it is wrong: .NET 8+ images use port 8080 and a non-root user; old manifests break. Instead: Set ASPNETCORE_HTTP_PORTS explicitly and update probes.

🏛 Senior insight: trade-offs

The senior lesson from a 'green but broken' release is that deployment safety is a property of the pipeline, not of careful people. The goal is a pipeline that physically can't promote a version that doesn't start: options validation that fails fast, readiness that exercises real dependencies, slot warm-up or canaries, and a smoke test that calls one real endpoint before traffic moves.

The second senior point is to decouple risky changes from code deployments. Schema migrations, secret moves and identity changes are the most common startup breakers, so they get their own steps with their own checks, done before the code that depends on them.

Option When it fits Cost When not to
Slot swap with warm-up App Service A second slot When the slot shares state you can't test before swap
Rolling update with readiness Kubernetes Correct probes When readiness checks nothing real
Canary with automated analysis High-traffic services Tooling (Argo Rollouts, Flagger) and metrics Low traffic: not enough signal
Separate migration step Any schema change Pipeline complexity, expand/contract discipline Never skip it for large tables

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions a migration failing during deployment Why: Checks rollback strategy for a half-applied migration
    How to answer

    First find out what state the database is actually in: read __EFMigrationsHistory, compare the schema with the expected script, and check the error. On SQL Server each migration normally runs in a transaction, so a failure usually rolls that migration back cleanly; the danger is statements EF Core runs outside a transaction and earlier migrations in the same batch that already committed.

    Then restore service: if the schema is still compatible with the previous app version, redeploy it. Fix the problem with a reviewed forward fix, not by running untested Down() methods. Point-in-time restore is the last resort, for real data damage, because it loses every write since the restore point.

    The trade-off: a forward fix keeps all data but takes thinking time; a restore is fast to start but expensive in lost writes.

  2. When: Candidate mentions slots, blue-green or canary Why: Checks deployment strategies and their rollback costs
    How to answer

    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.

  3. When: Candidate tells a story of a broken deployment Why: Checks the roll back versus roll forward decision
    How to answer

    First I mitigate, then diagnose. Alerts on 5xx and latency, annotated with the release, tell us the deployment is the likely cause. Then the key decision: roll back if the previous version still works with the current database and messages; roll forward only if rollback is unsafe (a contract change already happened) or the fix is tiny and certain. A feature flag kill switch beats both if the change was flagged.

    For migrations that already ran, I don't run down migrations on live data; additive changes stay, and if something destructive ran I restore compatibility (a view or computed column) or use point-in-time restore for the affected data.

    Afterwards: a blameless review and pipeline changes such as smoke tests, staged rollout, migration checks and automated rollback. The trade-off is speed of recovery versus certainty about cause.

🛠 Real-world problems: how you handle them

Slot swap broke production because the slot couldn't read Key Vault
Situation
An order API on [Azure App Service with a staging slot], deployed by [Azure DevOps]. A release moved the payments API key from app settings to Key Vault using a Key Vault reference.
Signals
Immediately after the swap, Azure Front Door reported 5xx responses from the origin; the App Service returned HTTP 500.30. Application Insights showed no requests from the new version. The pipeline was green.
Investigation
Swapped back to restore service (production was down for [14 minutes] before that). In the staging slot, the portal's Key Vault reference status showed the reference unresolved with a 403. The log stream showed `OptionsValidationException` for `Payments:ApiKey`. The staging slot had its own system-assigned identity, created when the slot was recreated, which had no role on the Key Vault.
Resolution
Immediate: swap back. Real fix: granted the slot's identity the Key Vault Secrets User role through Bicep, redeployed and swapped again after the warm-up passed.
Prevention
Added role assignments for both slots to Bicep, set `WEBSITE_SWAP_WARMUP_PING_PATH` to `/health/ready`, made readiness validate that required options and secrets load, and added a post-swap smoke test that calls one read-only endpoint and triggers an automatic swap back on failure.

How to tell it (STAR)

**S:** At [company], a release moved our payments key into Key Vault, the pipeline went green, and production started returning 500.30 straight after the slot swap. **T:** I was on the release and had to restore service and find out why the pipeline didn't catch it. **A:** I swapped back, then checked the staging slot: the Key Vault reference was unresolved with a 403, because the slot had its own managed identity with no role on the vault. I added the role assignments for both slots to Bicep, set a swap warm-up path pointing at a readiness check that validates required secrets, and added a smoke test that swaps back automatically. **R:** The outage was [14 minutes]; since then [two] broken releases have failed at the warm-up step instead of reaching customers.

↩ Usually asked after

More in Debugging Production Issues

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me