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.
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.
"Deployment in Aspire starts from the same AppHost model I run locally. I add a compute environment resource, for example
builder.AddAzureContainerAppEnvironment("env"), orAddKubernetesEnvironmentfor a cluster, and then there are two steps.aspire publishturns the model into artefacts: Bicep for Container Apps, a Helm chart for Kubernetes, Compose files for Docker.aspire deploygoes further and builds the container images, pushes them to a registry, provisions and applies everything. For Azure,azd uphas done the same for a while: it callsdotnet publishto 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 publishin 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 asWaitForCompletionin 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."
| 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 |
| 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 |
[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].
Checks whether the candidate understands what Aspire generates, how it gets to production safely, and where Aspire's responsibility ends.
Green flags
azd and the compute environment concept.Red flags
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(...).
AcrPull.services__* endpoints, OTEL_*).WithExternalHttpEndpoints().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.
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.
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.
azd pipeline config creates a GitHub Actions or Azure DevOps pipeline with OpenID Connect federated credentials (no stored secrets).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.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.
AddAzureContainerAppEnvironment("env") to a starter AppHost and run aspire publish; read every generated Bicep module.azd init then azd up in a dev subscription; compare the container apps' environment variables with the dashboard's.AddKubernetesEnvironment("k8s"), publish, and run helm template on the output.azd deploy.PublishAsAzureContainerApp to set min replicas to 2 and a CPU scale rule, and confirm it in the Bicep.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"
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.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.PublishAs... and ConfigureInfrastructure.WithExternalHttpEndpoints(). Why it is wrong: Internal services become internet-facing, enlarging the attack surface. Instead: Only the front door or gateway is external.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.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 |
I choose by how much platform the team wants to run:
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.
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.
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.
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.
Last updated 23 Nov 2026.