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

📚 Interview question

You are the senior engineer setting standards for new .NET services that will run on Azure Container Apps or AKS. What goes on your cloud-native service checklist? Cover statelessness, health, telemetry, resilience, configuration and secrets, security and operability, and explain how you would enforce it across teams without slowing them down.

Covers a cloud-native readiness checklist for .NET services: stateless design, probes and graceful shutdown, OpenTelemetry logs, metrics and traces, resilience and timeouts, externalised config and managed identity, container security, scaling and operability, and enforcing it through a service template, Aspire service defaults, pipeline gates and platform policy.

Senior Architecture Advanced architecture cloud-native health-checks opentelemetry platform-engineering production-readiness

🎯 Key points

  • Stateless and disposable: no local files or in-memory session; safe to kill any replica at any time
  • Health: startup, readiness and liveness endpoints with distinct jobs; graceful shutdown sized to the grace period
  • Telemetry: OpenTelemetry logs, metrics and traces with service.name and version; RED metrics and SLOs
  • Resilience: timeouts on every outbound call, standard resilience handler, idempotent handlers, bulkheads
  • Config and secrets: options validated on start, managed identity (ManagedIdentityCredential) to Key Vault and data stores, no secrets in images or repos
  • Supply chain and runtime security: NuGet audit, SBOM, image scanning and signing, non-root chiseled image, least-privilege identity, private networking
  • Operability: requests and limits set from load-test data, autoscaling rule, owner, runbook, dashboards and alerts
  • Enforce with a paved road: service template + shared service defaults + pipeline and Azure Policy gates

⏱ 30-second answer

My checklist has seven areas: stateless and disposable (any replica can be killed), health (startup, readiness and liveness probes with distinct jobs, plus graceful shutdown that fits the grace period), telemetry (OpenTelemetry logs, metrics and traces, an SLO and alerts), resilience (a timeout on every outbound call, the standard resilience handler, idempotent message handlers), configuration and secrets (validated options, managed identity, Key Vault), security (non-root chiseled images, scanning, least-privilege identity, private networking) and operability (resource requests, an autoscale rule, an owner and a runbook).

I enforce it with a paved road, not a document: a service template and shared service-defaults package that make the right thing the default, plus a few automated gates in the pipeline and Azure Policy. The trade-off is standardisation versus team autonomy, so I gate only what protects production.

🗣 Full answer (senior)

How I would answer this in an interview

"A cloud-native service is one the platform can start, scale, move and stop without a human, and that tells you what it is doing while it runs. My checklist follows from that. Stateless: no files on local disk, no in-memory session, Data Protection keys shared. Health: a startup probe, a readiness probe that fails during warm-up and shutdown, and a liveness probe that checks only the process. Telemetry: OpenTelemetry for traces, metrics and logs with a service.name and version, so a request can be followed across services. Resilience: every outbound call has a timeout, retries happen in one place, and message handlers are idempotent. Config: validated options with ValidateOnStart, managed identity instead of connection-string passwords. Security: non-root chiseled images, scanned and signed. Operability: requests and limits, an autoscale rule, an owner, dashboards and a runbook.

The hard part is not the list, it is getting [n] teams to follow it. For example, at [company] we [had a wiki checklist nobody read]. I [built a service template and a shared ServiceDefaults package, modelled on Aspire's, that wired OpenTelemetry, health endpoints, resilience and JSON logging with one call, and added three pipeline gates: image scan, probes present, no secrets]. [New services went from about two weeks of production hardening to two days, and checklist-related incidents dropped from N to M per quarter.]

The mistake I see is a 60-item checklist enforced in a review meeting. It slows teams down and still misses things. I keep the blocking list short, about ten items that prevent outages or breaches, automate those, and make the rest advice built into the template."


The checklist

Area Must have (blocking) Should have
Stateless No local writes outside /tmp; session and Data Protection keys external Read-only root file system
Health /health/ready, /health/live, startup probe; ShutdownTimeout < grace period Warm-up before readiness
Telemetry OpenTelemetry traces + metrics + structured logs; service.name, service.version SLO with burn-rate alerts
Resilience Timeout on every outbound call; one retry layer; idempotent consumers Bulkheads, load shedding, rate limits
Config and secrets Options validated on start; no secrets in image or repo; managed identity App Configuration, feature flags
Security Non-root, chiseled/distroless image; image scanning; HTTPS; least-privilege RBAC Image signing, private endpoints, network policies
Operability CPU/memory requests and limits; autoscale rule; owner and on-call; runbook Load test result, cost tag

How to enforce it

Mechanism What it enforces Cost
Service template (dotnet new) Project layout, Dockerfile, probes, Program.cs Template maintenance
Shared ServiceDefaults package OpenTelemetry, health checks, resilience, logging Versioning across teams
Pipeline gates Image scan, tests, secret scan, manifest lint (probes, limits) Some build time
Azure Policy / Kubernetes admission (Gatekeeper, Kyverno) Non-root, no latest tag, limits set, approved registries Platform team effort
Scorecard (e.g. Backstage) Visibility of the should-haves Portal to run

Production example

A platform of 18 .NET services had seven incidents in a quarter traced to missing timeouts, absent probes or secrets in config files. After a template plus shared defaults and four pipeline gates, new services passed production review in one pass, and the next two quarters had one incident of that kind.

🔍 What the interviewer is checking

Checks whether the candidate can define production readiness for cloud-native .NET services and, more importantly, drive adoption across teams.

Green flags

  • Covers all areas with concrete mechanisms (probes, OpenTelemetry, resilience handler, managed identity, chiseled images)
  • Separates blocking items from advice
  • Enforces through templates, shared defaults and automated gates rather than meetings
  • Measures outcomes (incidents, lead time)

Red flags

  • A list of buzzwords with no .NET mechanism
  • Relies on manual review for everything
  • Ignores security or operability (owner, runbook, limits)

📚 Learn in depth

1. What "cloud-native" actually requires

The CNCF definition talks about containers, service meshes, microservices, immutable infrastructure and declarative APIs, but the operational core is simpler: the platform must be able to manage the process without a human, and humans must be able to understand it from the outside.

         Platform needs                         Humans need
  +-------------------------------+     +-----------------------------+
  | start fast, report readiness  |     | traces across services      |
  | stop gracefully on SIGTERM    |     | metrics: rate, errors, p99  |
  | scale by adding replicas      |     | structured logs with ids    |
  | config injected at run time   |     | an owner and a runbook      |
  | resource needs declared       |     | SLOs and alerts             |
  +-------------------------------+     +-----------------------------+

Every checklist item maps to one of these boxes.

2. The service-defaults idea

Aspire's ServiceDefaults project shows the pattern: one extension method, AddServiceDefaults(), configures OpenTelemetry (ASP.NET Core, HttpClient and runtime instrumentation, OTLP export), default health checks, service discovery and AddStandardResilienceHandler for every HttpClient, and MapDefaultEndpoints() maps /health and /alive. An organisation can publish its own version as an internal NuGet package with its conventions (JSON console logs, Azure Monitor exporter, health endpoint names, required resource attributes). Teams get the checklist for one line of code, and the platform team upgrades everyone by releasing a new package version.

3. Telemetry details that matter

  • Resource attributes: service.name, service.version, deployment.environment.name. Without them, traces from 18 services are unreadable.
  • RED metrics (rate, errors, duration) come from Microsoft.AspNetCore.Hosting and System.Net.Http meters, built into .NET 8+.
  • Sampling: head-based sampling at 5-20% for high-volume services, or tail-based sampling in an OpenTelemetry Collector to keep all errors.
  • Cost: logs are usually the biggest bill; set minimum levels per category and avoid logging request bodies, especially personal information under the Privacy Act.

4. Resilience details

Timeouts must shrink down the chain (gateway 10 s > service 5 s > dependency 2 s). Retries only for idempotent operations and only at one layer. A circuit breaker stops hammering a failing dependency. For messaging, idempotent handlers plus a dead-letter queue with an alert. Rate limiting (AddRateLimiter) and concurrency limits protect the service from its callers.

5. Container and security baseline

  • Chiseled or distroless .NET images (mcr.microsoft.com/dotnet/aspnet:10.0-noble-chiseled), non-root user (UID 1654 app in the official images), port 8080.
  • readOnlyRootFilesystem: true with an emptyDir for /tmp.
  • Image scanning (Microsoft Defender for Containers, Trivy) and signing (Notation) in the pipeline; admission policy that only allows signed images from your registry.
  • Least-privilege managed identity per service; private endpoints for data stores. These line up with the ACSC Essential Eight (patch applications, restrict administrative privileges, application control).

6. Operability

CPU and memory requests let the scheduler place pods; a memory limit stops one leak from taking down a node (and .NET reads cgroup limits to size the GC heap). An autoscale rule (HPA on CPU, or KEDA on queue length / HTTP concurrency in Container Apps) and a pod disruption budget keep capacity during node maintenance. Each service has an owning team, an on-call rota and a runbook linked from its alerts.

Try it yourself

  1. Create an internal ServiceDefaults class library with AddServiceDefaults() and use it in two minimal APIs; view both in the Aspire dashboard.
  2. Write a Kyverno or Gatekeeper policy that rejects pods without readiness probes or with runAsNonRoot: false, and test it in kind.
  3. Run trivy image on an sdk image and on a chiseled aspnet image and compare the vulnerability counts.
  4. Kill a random pod every 30 seconds during a k6 load test and check the error rate stays flat.
  5. Turn on readOnlyRootFilesystem and find what in your app still writes to disk.

💻 Code

An organisation-level service-defaults package (modelled on Aspire's) that turns most of the checklist into one call.

// Contoso.ServiceDefaults/Extensions.cs (.NET 10 class library, FrameworkReference Microsoft.AspNetCore.App)
namespace Microsoft.Extensions.Hosting;

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;

public static class ServiceDefaultsExtensions
{
    public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
    {
        // Telemetry: one resource identity for logs, metrics and traces.
        builder.Logging.AddOpenTelemetry(o => { o.IncludeFormattedMessage = true; o.IncludeScopes = true; });
        builder.Services.AddOpenTelemetry()
            .ConfigureResource(r => r.AddService(builder.Environment.ApplicationName,
                serviceVersion: typeof(ServiceDefaultsExtensions).Assembly.GetName().Version?.ToString()))
            .WithMetrics(m => m.AddAspNetCoreInstrumentation().AddHttpClientInstrumentation().AddRuntimeInstrumentation())
            .WithTracing(t => t.AddAspNetCoreInstrumentation(o => o.Filter = ctx => !ctx.Request.Path.StartsWithSegments("/health"))
                               .AddHttpClientInstrumentation())
            .UseOtlpExporter(); // endpoint from OTEL_EXPORTER_OTLP_ENDPOINT: Collector, Aspire dashboard or Azure Monitor

        // Health: liveness has no checks; readiness checks are tagged "ready" by each service.
        builder.Services.AddHealthChecks().AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);

        // Resilience: every HttpClient gets timeouts, retries and a circuit breaker.
        builder.Services.ConfigureHttpClientDefaults(http => http.AddStandardResilienceHandler());

        // Disposability: fits preStop 10 s + 25 s inside a 40 s grace period.
        builder.Services.Configure<HostOptions>(o => o.ShutdownTimeout = TimeSpan.FromSeconds(25));
        return builder;
    }

    public static WebApplication MapDefaultEndpoints(this WebApplication app)
    {
        app.MapHealthChecks("/health/live", new HealthCheckOptions { Predicate = c => c.Tags.Contains("live") });
        app.MapHealthChecks("/health/ready", new HealthCheckOptions { Predicate = c => c.Tags.Contains("ready") });
        return app;
    }
}
// A team's service: the checklist costs two lines.
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.Services.AddHealthChecks().AddSqlServer(builder.Configuration.GetConnectionString("Orders")!, tags: ["ready"]);
var app = builder.Build();
app.MapDefaultEndpoints();
app.MapGet("/orders/{id:int}", (int id) => Results.Ok(new { id }));
app.Run();
# Pipeline gate idea: reject manifests missing the basics (conftest / Kyverno-style rule, pseudo-policy)
require:
  - spec.template.spec.containers[*].readinessProbe
  - spec.template.spec.containers[*].resources.requests.memory
  - spec.template.spec.securityContext.runAsNonRoot == true
deny:
  - image tag == "latest"

⚠ Common mistakes

  • Mistake: Publishing a long checklist and enforcing it in review meetings. Why it is wrong: Teams see it as bureaucracy, reviews become a bottleneck and items still slip. Instead: Build the checklist into a template and shared defaults, and automate a short blocking list.
  • Mistake: Making every item blocking. Why it is wrong: Teams route around the process or stop shipping. Instead: Block only what prevents outages or breaches; show the rest on a scorecard.
  • Mistake: Copy-pasting telemetry and health set-up into each service. Why it is wrong: Copies drift, and fixing a bug means editing every repo. Instead: Ship a versioned ServiceDefaults package.
  • Mistake: Treating "runs in a container" as cloud-native. Why it is wrong: A stateful app with no probes or telemetry in a container fails the same way as on a VM, only faster. Instead: Check behaviour: kill a replica under load and watch the error rate.
  • Mistake: Health checks that hit every dependency for liveness. Why it is wrong: A shared dependency blip restarts the whole fleet. Instead: Liveness checks the process; readiness checks only what this instance needs.
  • Mistake: No resource requests or memory limits, or values guessed once and never revisited. Why it is wrong: The scheduler overpacks nodes, one leak evicts neighbours, and a CPU limit set too low throttles the app (CFS throttling) and inflates p99 latency. Instead: Run a load test at expected peak, watch dotnet-counters (GC heap, working set, CPU) and container metrics (container_memory_working_set_bytes, CPU throttling), set the memory request near steady-state working set and the limit with 25-50% headroom, set the CPU request at typical usage, and revisit after major releases. .NET sizes its GC heap from the cgroup memory limit (75% by default via GCHeapHardLimitPercent).
  • Mistake: Scanning images but ignoring the build supply chain. Why it is wrong: A compromised or vulnerable NuGet package ships inside a clean base image. Instead: Turn on NuGet audit (NuGetAudit, on by default in .NET 9+ SDKs, including transitive packages), lock files and package source mapping, generate an SBOM, and sign images so admission only accepts what your pipeline built.
  • Mistake: Collecting telemetry without an SLO or owner. Why it is wrong: Dashboards nobody watches catch nothing. Instead: Define an SLO per service with burn-rate alerts routed to the owning team.

🏛 Senior insight: trade-offs

The checklist itself is easy to write; the senior contribution is the delivery mechanism. The best checklists are invisible: a team runs dotnet new contoso-api, gets a service that already has telemetry, probes, resilience and a hardened Dockerfile, and only meets the gates when they deliberately go off the road. Keep the blocking set small and objective (machine-checkable), and treat the template like a product with a changelog and an owner.

Enforcement option When it fits Cost When not to
Written checklist + review 1-3 teams, early days Reviewer time, inconsistency More than a handful of services
Template + shared defaults Many teams on one stack Maintaining the template and package Very heterogeneous stacks
Policy as code (Azure Policy, Kyverno) Security and platform invariants Platform team effort, exceptions process Style preferences
Scorecards (Backstage) Visibility across 20+ services Portal to operate Small estates

Measure success by lead time for a new service to reach production and by the number of incidents whose root cause is a checklist item.

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions shared service defaults or AddServiceDefaults Why: Checks they know what Aspire's service defaults wire up and what to change for production.
    How to answer

    Service defaults is a shared class library that each service calls with builder.AddServiceDefaults(). It is code you own, generated by the template:

    • OpenTelemetry: logs, traces and metrics with ASP.NET Core, HttpClient and runtime instrumentation, exported over OTLP when OTEL_EXPORTER_OTLP_ENDPOINT is set.
    • Health checks: a self check; MapDefaultEndpoints() maps /health (readiness) and /alive (liveness), only in Development by default.
    • Every HttpClient gets service discovery and the standard resilience handler (timeouts, retries, circuit breaker).

    It is a starting baseline, not a finished production configuration. Before production each service tunes retries for non-idempotent calls, decides how health endpoints are exposed, registers its own ActivitySource and Meter names, and sets sampling.

  2. When: Candidate mentions health checks in the checklist Why: Checks they can design truthful liveness, readiness and startup checks across a fleet.
    How to answer

    A health check is an automated decision: the orchestrator or load balancer acts on it, so it must answer exactly the question the actor asks. Liveness asks "is this process stuck?", so the answer is a restart. It never checks shared dependencies. Readiness asks "should this instance get traffic now?" It checks warm-up and local essentials, not something every instance shares. Startup probes give slow starts time before liveness applies.

    The classic failure is a database check in liveness or readiness: one database blip makes every instance fail together. You get a fleet restart or zero healthy backends, which turns a partial outage into a total one. In ASP.NET Core I use tagged checks mapped to separate endpoints, keep them cheap and time-boxed, and keep detailed output internal. Dependency health goes to monitoring and alerts, where a human decides.

  3. When: Candidate mentions container security in the checklist Why: Checks they can spot and fix Dockerfile and Deployment problems in review.
    How to answer

    I rank by blast radius. Blocking first: the database password in a plain env var in Git (rotate it now, then use Workload Identity with Entra authentication to Azure SQL, or Key Vault); running as root on the SDK image (huge attack surface, compilers and a shell for an attacker: multi-stage build, chiseled runtime, runAsNonRoot).

    Then reliability: :latest (you can't tell what's running or roll back: use version or SHA tags), no probes (traffic hits unready pods, hung pods never restart), no requests or limits (noisy neighbours, evictions, and .NET sizing itself to the whole node), one replica (downtime on every deploy).

    Then diagnostics and polish: exec-form entry point for SIGTERM, .dockerignore, labels. I close with policy so the cluster rejects these by default.

🛠 Real-world problems: how you handle them

Seven incidents in a quarter from missing basics
Situation
A platform of [18] .NET services across [5] teams moving from App Service to Azure Container Apps; each team had built its own hosting set-up.
Signals
[7] incidents in one quarter: a hung dependency call with no timeout exhausting threads, pods killed by liveness during start-up, a connection string committed to a repo, and two services with no traces, which made incidents slow to diagnose.
Investigation
Ran a blameless review across all seven post-incident reports and tagged the root causes; [6] of [7] were a missing baseline item rather than a business-logic bug. Audited all services against a draft checklist with a script reading manifests and Program.cs, and found wide variation in probes, timeouts and telemetry.
Resolution
Immediate: fixed the specific gaps in the affected services. Long term: built a `dotnet new` template and an internal ServiceDefaults NuGet package (OpenTelemetry, health endpoints, resilience, JSON logs), added pipeline gates for image scanning, secret scanning and manifest lint, and Azure Policy for non-root and approved registries.
Prevention
A scorecard per service, the template owned by the platform team with a changelog, an ADR for the blocking list, and a quarterly review of incidents mapped to checklist items.

How to tell it (STAR)

**S:** We had [18] .NET services moving to Container Apps, and [7] incidents in one quarter. **T:** As [senior engineer on the platform group], I was asked to stop repeat incidents without slowing teams down. **A:** I tagged the root causes from every post-incident review and showed that [6] were missing basics: no timeouts, wrong probes, secrets in config, no traces. Instead of a longer checklist, I built a service template and a shared ServiceDefaults package so the basics came for free, and automated four blocking gates in the pipeline. **R:** New services reached production in [2 days instead of 2 weeks], and checklist-type incidents fell from [7] to [1] over the next two quarters.

↩ Usually asked after

More in Cloud-Native Patterns

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me