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

📚 Interview question

How do you deploy an Aspire application? Explain aspire publish and aspire deploy, azd up to Azure Container Apps, generating Kubernetes (Helm) or Docker Compose output, how secrets, identity and the database get handled, and what Aspire does and doesn't do for you in production.

Deploying Aspire apps: compute environments (Container Apps, Kubernetes, Docker Compose, App Service), aspire publish vs aspire deploy vs azd, generated Bicep and Helm, parameters and secrets, managed identity, migrations, CI/CD, and Aspire's responsibilities and limits in production.

Senior Theory Advanced azd azure-container-apps cloud-native deployment dotnet-aspire kubernetes

🎯 Key points

  • The AppHost model is the input; a compute environment resource (AddAzureContainerAppEnvironment, AddKubernetesEnvironment, AddDockerComposeEnvironment) decides the target
  • aspire publish writes artefacts (Bicep, a Helm chart, Compose files) for review and your own pipeline; aspire deploy builds and pushes images and applies them (check the current docs for maturity: at the time of writing, November 2026, Microsoft marks Container Apps deploy as preview)
  • azd up = package (dotnet publish container images) + provision (Bicep) + deploy; azd pipeline config generates a GitHub Actions or Azure DevOps workflow that runs the same steps with OIDC federated credentials
  • Container Apps output: environment, Azure Container Registry, Log Analytics, one container app per project, user-assigned managed identity with RBAC role assignments, internal ingress unless WithExternalHttpEndpoints
  • Secret parameters become secure Bicep parameters or prompts and Container Apps secrets; prefer Key Vault references and managed identity over keys
  • Aspire does not run in production: no orchestrator, no DCP; the platform handles scaling, revisions, probes, certificates and networking
  • Things you still own: database migrations as a pipeline step or job, private networking, custom domains, scaling rules, probes, sampling, environments and approvals
  • After each deployment: smoke tests and load tests against the new revision, SLO dashboards and alerts in Application Insights, and traffic splitting between revisions for safe rollout

⏱ 30-second answer

The AppHost model is the input to deployment. You add a compute environment (Azure Container Apps, Kubernetes, Docker Compose or App Service) and then:

  • aspire publish generates artefacts: Bicep for Azure, a Helm chart for Kubernetes, or Compose files, for review and your own pipeline.
  • aspire deploy builds and pushes images and applies them; for Container Apps it's still marked preview in Microsoft's docs.
  • azd up packages, provisions (Bicep) and deploys to Container Apps, and azd pipeline config creates CI/CD with federated credentials.

Deployed apps use managed identity and secret parameters, not keys. Aspire itself doesn't run in production: the platform handles scaling, revisions, probes and networking. You still own migrations, private networking, scaling rules, environments and approvals. The trade-off: one model from laptop to cloud, versus generated infrastructure you must review and sometimes override.

🗣 Full answer (senior)

How I would answer this in an interview

"Deployment in Aspire starts from the same AppHost model I run locally. I add a compute environment resource, for example builder.AddAzureContainerAppEnvironment("env"), or AddKubernetesEnvironment for a cluster, and then there are two steps. aspire publish turns the model into artefacts: Bicep for Container Apps, a Helm chart for Kubernetes, Compose files for Docker. aspire deploy goes further and builds the container images, pushes them to a registry, provisions and applies everything. For Azure, azd up has done the same for a while: it calls dotnet publish to build images, provisions the Bicep, and deploys one container app per project, with a registry, a Log Analytics workspace and a managed identity with the right role assignments.

For a production system I don't deploy from a laptop. At [company] we [ran aspire publish in CI, committed nothing generated, reviewed the Bicep diff in the pull request, and deployed through a pipeline with environment approvals]. Secret parameters became secure Bicep parameters and Container Apps secrets backed by Key Vault, and every service used managed identity for SQL, Service Bus and Storage. Database migrations ran as a separate pipeline step with an EF Core migration bundle, never as WaitForCompletion in production. [The first production release took two days instead of the two weeks our previous hand-written Bicep had taken].

The mistake I see is thinking Aspire runs in production. It doesn't: there's no orchestrator or dashboard in prod by default. Container Apps or Kubernetes does scaling, revisions, probes, certificates and networking, and things like private endpoints, custom domains, KEDA scaling rules and sampling are still mine to configure. Aspire gets you to a correct first deployment quickly, but production still needs the same engineering it always did."


Deployment targets (as of November 2026)

Target AppHost API aspire publish output Notes
Azure Container Apps AddAzureContainerAppEnvironment Bicep Most mature; also via azd
Kubernetes (AKS or any cluster) AddKubernetesEnvironment (+ WithHelm) Helm chart aspire deploy can install with your kubectl context
Docker Compose AddDockerComposeEnvironment docker-compose.yaml + .env Simple VMs, on-premises
Azure App Service App Service environment integration Bicep For teams standardised on App Service

Who does what in production

Concern Aspire Platform You
Describe topology and wiring Yes Review
Generate infrastructure Yes (Bicep, Helm, Compose) Review, customise
Run, scale, restart containers Yes Scaling rules
TLS, ingress, domains Basic ingress flags Yes Domains, certificates, WAF
Identity Role assignments generated Managed identity Least privilege review
Database schema Migrations step or job
Observability OTLP set-up via service defaults Log Analytics Exporter, sampling, alerts
Network isolation Limited VNets, private endpoints Design and configure

Production example

[A .NET 10 order platform with five services, Azure SQL and Service Bus] moved from hand-written Bicep to aspire publish in a pipeline. Infrastructure for a new service went from [about three days] to [under an hour], and because each service had its own user-assigned identity with only the roles it needed, a security review found [zero] shared keys, down from [eleven].

🔍 What the interviewer is checking

Checks whether the candidate understands what Aspire generates, how it gets to production safely, and where Aspire's responsibility ends.

Green flags

  • Explains publish vs deploy vs azd and the compute environment concept.
  • Describes the Container Apps output, managed identity and internal vs external ingress.
  • Handles migrations and secrets properly.
  • States clearly what the platform and the team still own.

Red flags

  • Believes Aspire runs in production.
  • Deploys production from a laptop.
  • Runs migrations on start-up in every replica.
  • Has never read the generated infrastructure.

📚 Learn in depth

1. From model to artefacts

AppHost model (resources + references + compute environment)
        |
        +-- aspire publish ---> ./aspire-output/
        |                        main.bicep, env/*.bicep, app modules   (Container Apps)
        |                        Chart.yaml, templates/*.yaml, values.yaml (Kubernetes)
        |                        docker-compose.yaml, .env              (Compose)
        |
        +-- aspire deploy  ---> build images -> push to registry -> provision/apply
        |
        +-- azd up         ---> azd package (dotnet publish /t:PublishContainer)
                                azd provision (Bicep)  ->  azd deploy (container app revisions)

Publish works through publishers attached to compute environment resources. Each resource (project, container, Azure resource) contributes to the output for its environment. You can customise per resource with PublishAsAzureContainerApp((infra, app) => ...) or PublishAsKubernetesService(...).

2. What the Container Apps output contains

  • A Container Apps environment with a Log Analytics workspace.
  • An Azure Container Registry and a user-assigned managed identity with AcrPull.
  • One container app per project or container, with environment variables matching what the AppHost injected locally (connection strings, services__* endpoints, OTEL_*).
  • Internal ingress by default; external only for resources marked WithExternalHttpEndpoints().
  • Role assignments for Azure resources the app references (e.g. Service Bus Data Sender), so clients use managed identity.

What it doesn't contain unless you add it: private endpoints and VNet integration choices, custom domains and certificates, KEDA scale rules beyond defaults, Front Door or a WAF, diagnostic settings to your central workspace.

3. Parameters and secrets

AppHost parameters become deployment inputs: azd prompts once and stores values in the environment's .azure folder; CI supplies them as pipeline variables or secrets. Secret parameters become @secure() Bicep parameters and Container Apps secrets. Better still, resources like Azure SQL and Service Bus use Entra ID with managed identity, so there's no secret at all.

4. Databases and migrations

Locally, a migrations project with WaitForCompletion is convenient. In production, migrations should run once, with appropriate privileges, before the new revision takes traffic: an EF Core migration bundle (dotnet ef migrations bundle) as a pipeline step, or a Container Apps job. Running Database.Migrate() in every replica at start-up races between replicas and needs DDL rights in the app's identity.

5. CI/CD

  • azd pipeline config creates a GitHub Actions or Azure DevOps pipeline with OpenID Connect federated credentials (no stored secrets).
  • Alternatively run aspire publish in CI, store the output as a build artefact, review the diff, and deploy with az deployment group create or Helm per environment with approvals.
  • Use separate environments (dev, test, prod) with separate subscriptions or resource groups in Australia East, and a paired region such as Australia Southeast for DR if required.

6. Kubernetes specifics

AddKubernetesEnvironment("k8s").WithHelm(...) generates a chart: Deployments, Services, ConfigMaps and Secrets per resource. aspire deploy can build and push images and run helm upgrade --install using your current kubectl context, and AddHelmChart can install extra charts. Many platform teams prefer to take the generated chart as a starting point and own it in GitOps (Argo CD or Flux), because ingress controllers, network policies, PodDisruptionBudgets and resource limits are platform decisions.

Try it yourself

  1. Add AddAzureContainerAppEnvironment("env") to a starter AppHost and run aspire publish; read every generated Bicep module.
  2. Run azd init then azd up in a dev subscription; compare the container apps' environment variables with the dashboard's.
  3. Add AddKubernetesEnvironment("k8s"), publish, and run helm template on the output.
  4. Create an EF Core migration bundle and run it as a pipeline step before azd deploy.
  5. Use PublishAsAzureContainerApp to set min replicas to 2 and a CPU scale rule, and confirm it in the Bicep.

💻 Code

An AppHost prepared for Container Apps deployment, with production-specific customisation.

// AppHost/Program.cs
using Azure.Provisioning.AppContainers;

var builder = DistributedApplication.CreateBuilder(args);

builder.AddAzureContainerAppEnvironment("env");            // compute target for publish/deploy

var sql = builder.AddAzureSqlServer("sql")                   // Azure SQL with Entra ID auth when deployed
                 .RunAsContainer();                          // local: SQL Server container
var ordersDb = sql.AddDatabase("orders");

var messaging = builder.AddAzureServiceBus("messaging").RunAsEmulator();
messaging.AddServiceBusQueue("orders");

builder.AddProject<Projects.Orders_Api>("api")
       .WithReference(ordersDb)
       .WithReference(messaging)
       .WithExternalHttpEndpoints()                          // only the API is public
       .PublishAsAzureContainerApp((infra, app) =>
       {
           app.Template.Scale.MinReplicas = 2;               // no cold starts, survives a replica loss
           app.Template.Scale.MaxReplicas = 10;
       });

builder.AddProject<Projects.Orders_Worker>("worker")
       .WithReference(ordersDb)
       .WithReference(messaging);                            // internal only

builder.Build().Run();
# Generate artefacts for review in CI
aspire publish -o ./aspire-output

# Or provision + deploy with azd (dev environment)
azd init            # detects the AppHost
azd up              # package images, provision Bicep, deploy revisions
azd pipeline config # GitHub Actions / Azure DevOps with federated credentials

# Production migrations: run once, before the new revision takes traffic
dotnet ef migrations bundle --project src/Orders.Data -o efbundle --self-contained -r linux-x64
./efbundle --connection "$ORDERS_DB_CONNECTION"

⚠ Common mistakes

  • Mistake: Thinking the Aspire orchestrator or dashboard runs in production. Why it is wrong: Production runs on Container Apps, Kubernetes or App Service; DCP is a local tool. Instead: Treat Aspire as the model and generator; the platform runs the workload.
  • Mistake: Deploying production from a developer laptop with azd up. Why it is wrong: No review, no approvals, no audit trail, and the developer needs broad rights in production. Instead: Use azd pipeline config or aspire publish in CI with environment approvals and federated credentials.
  • Mistake: Running migrations with WaitForCompletion or Database.Migrate() in production. Why it is wrong: Replicas race, the app identity needs DDL rights, and a failed migration takes the app down. Instead: A migration bundle step or a Container Apps job before the new revision.
  • Mistake: Not reviewing generated Bicep or Helm. Why it is wrong: Defaults may expose endpoints publicly, skip private networking or pick unsuitable SKUs. Instead: Review the diff in every pull request and customise with PublishAs... and ConfigureInfrastructure.
  • Mistake: Marking every project WithExternalHttpEndpoints(). Why it is wrong: Internal services become internet-facing, enlarging the attack surface. Instead: Only the front door or gateway is external.
  • Mistake: Keeping connection strings with passwords as secret parameters. Why it is wrong: Secrets need rotation and can leak. Instead: Entra ID authentication with managed identity for Azure SQL, Service Bus and Storage.
  • Mistake: Assuming aspire deploy for Container Apps is GA everywhere. Why it is wrong: Microsoft's docs still mark parts of it as preview, so behaviour can change between minor versions. Instead: Pin the Aspire version, and use aspire publish plus your own pipeline where stability matters.

🏛 Senior insight: trade-offs

I use Aspire's deployment support to get the first correct deployment fast, then I make conscious decisions about what Aspire keeps owning. For a team that owns its whole stack on Container Apps, generated Bicep plus customisation is usually enough. In an organisation with a platform team, landing zones and GitOps, I treat the generated chart or Bicep as a starting point and the platform's IaC remains the source of truth.

Where azd fits in CI/CD. azd is not a CI system; it's a CLI that the pipeline calls. azd pipeline config creates the workflow file and a federated credential, and the workflow runs azd provision and azd deploy per environment (azd env holds each environment's parameters). That gives reproducible, secret-free deployments, but you still add the parts that make a release safe: build and test stages, a Bicep what-if or aspire publish diff for review, environment approvals, and a migration step before deploy.

Deployment isn't finished when the revision is running. I gate promotion on smoke tests against the new revision's URL, a short k6 load test in test environments, and the service's SLO dashboard and burn-rate alerts in Application Insights. With Container Apps' multiple-revision mode I shift traffic gradually (10%, 50%, 100%) and roll back by moving traffic, not by redeploying.

Path When it fits Cost When not to
azd up Dev and test environments, small teams on Container Apps Less control over pipeline shape Regulated production without review
azd in a generated pipeline Small teams wanting secret-free CI quickly Extend it with tests and approvals Complex multi-stage release processes
aspire publish + own pipeline Production, reviewed IaC, approvals Pipeline work Prototypes
aspire deploy Quick end-to-end deploys, Kubernetes with kubectl access Preview features; less separation of duties Strict change control
Platform-owned IaC, Aspire for local only Landing zones, GitOps, shared clusters Two models to keep aligned Small teams owning everything

🔗 Follow-ups the interviewer may ask

  1. When: Candidate picks Container Apps as the target Why: Checks choosing between App Service, Functions, Container Apps and AKS
    How to answer

    I choose by how much platform the team wants to run:

    • App Service: one or a few web apps, always on, deployment slots, almost no ops. Paid per plan instance.
    • Azure Functions: event-driven or spiky work (queues, timers, blobs); Flex Consumption scales per event and to zero.
    • Container Apps: containerised microservices on managed Kubernetes with KEDA scaling, revisions and scale to zero, without touching the cluster.
    • AKS: full Kubernetes when you need its API, custom networking or many services and have a platform team.

    The trade-off is control versus operations: each step towards AKS gives more control and more work. I start with the simplest option that meets the requirements and move only when I hit a concrete limit.

  2. When: Candidate mentions running migrations in the pipeline Why: Checks safe EF Core migrations in CI/CD
    How to answer

    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.

  3. When: Candidate mentions the generated Helm chart Why: Checks Helm knowledge for the Kubernetes path
    How to answer

    Helm is the package manager for Kubernetes. A chart is a set of manifest templates (Go templating) plus a values.yaml of defaults. You install it as a release, overriding values per environment with files like values-prod.yaml. Helm stores each revision in the cluster, so helm upgrade --install --atomic deploys and helm rollback returns to an earlier revision. Charts are versioned and pushed to OCI registries such as Azure Container Registry.

    Kustomize takes the opposite approach: plain YAML bases with environment overlays and patches, no templating, built into kubectl apply -k.

    I use Helm when a chart is shared across many services or for third-party software, and Kustomize for simple in-house overlays. The trade-off: Helm's power versus template complexity.

🛠 Real-world problems: how you handle them

First production deployment of an Aspire app exposed internal services publicly
Situation
[Claims-processing platform] with [six .NET 10 services], Azure SQL and Service Bus, handling personal information, deployed to Azure Container Apps in Australia East with `azd up` from a pipeline.
Signals
A pre-go-live penetration test found [four] internal services reachable from the internet; Defender for Cloud flagged container apps with external ingress and a SQL server with public network access enabled.
Investigation
Read the AppHost: a copied snippet added `WithExternalHttpEndpoints()` to every project. Ran `aspire publish` and diffed the Bicep against the intended design; checked the Container Apps environment's ingress settings and the SQL server networking in the portal.
Resolution
Immediate: switched the four services to internal ingress in the portal and disabled SQL public access with a private endpoint. Real fix: removed `WithExternalHttpEndpoints()` from internal services, added `ConfigureInfrastructure` to disable public network access on SQL and Service Bus, used a VNet-integrated environment, and redeployed through the pipeline.
Prevention
Pull request check that publishes and diffs the Bicep with an automated rule failing on new external ingress; Azure Policy denying public network access in production subscriptions; an ADR listing which services may be external.

How to tell it (STAR)

**S:** Two weeks before go-live of our [claims platform], the penetration test found [four] internal services and the SQL server reachable from the internet. **T:** As [tech lead], I had to close it before go-live and make sure it couldn't come back. **A:** I traced it to a copied AppHost line that made every service external, locked things down immediately, then fixed the model, added network hardening through `ConfigureInfrastructure`, and added a pipeline check that fails when the generated Bicep adds public exposure, backed by Azure Policy. **R:** The retest found [zero] exposed internal endpoints, and the check has since blocked [two] accidental changes.

↩ Usually asked after

More in .NET Aspire

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me