TIMEWARP SKILL — deploy a generated app from its Aspire AppHost. The first deploy is one command, dev deploy --target <t>: publish, deploy, migrate when the app has a database, smoke the ingress, and open the app (--no-browser prints the URL). Targets: Docker Compose, Kubernetes/Helm, Azure (AKS or Azure Container Apps), and Azure Container Apps + Neon. dev publish, dev deploy migrate, dev open, and dev deprovision are one-step operator verbs (never CI). Also: kind, production safety, secrets and parameters, the passkey ingress host, migrations per target, ingress topology, container-runtime neutrality. Invoke before deploying, adding a publish target, or touching publish-mode wiring in the AppHost. WHEN: deploy the app, first deploy, dev deploy, dev deprovision, dev open, migrate the deployed database, tear down a deployment, kind cluster, Helm, AKS, Azure Container Apps, Neon region, passkeys on a deployed host, production secrets, Podman.
Maintained in timewarp-architecture · Canonical file: SKILL.md
Install
With TimeWarp.Skills:
dnx TimeWarp.Skills -- add tw-deploy https://timewarp.software/
Add a harness target and skills sync (see the TimeWarp.Skills page). Or copy the SKILL.md into your agent's skills directory.
Deploy (Aspire publish targets)
The AppHost (source/container-apps/aspire/projects/aspire-app-host/) is the single
source of truth for deployment. Every deployment artifact — docker-compose.yaml, .env, the
Helm chart, the migration script — is generated by aspire publish / aspire deploy. There
are no hand-written Dockerfiles, manifests, or charts, and there is no devops/ tree. The
AppHost Design regions hold the per-line reasoning (program.cs maps each concern to its file);
this skill is the operator's map.
Detection — when to invoke
| Signal | Where |
|---|---|
Deploying the app anywhere other than dev run |
any target below |
| Adding or changing a publish target / compute environment | AppHost publish-target.cs |
| Adding a setting that must differ in production | parameters, not literals |
Touching code guarded by IsPublishMode / IsRunMode |
AppHost program.cs and its concern files |
| Adding a schema migration that must reach production | migrations section |
Target matrix
| Target | AppHost environment | Publish:Target |
Artifact | Run with |
|---|---|---|---|---|
| Standalone hardware | AddDockerComposeEnvironment("compose") |
compose (default) |
docker-compose.yaml + .env + efmigrations/ |
aspire deploy, or docker compose up / podman compose up |
| Kubernetes (on-prem, any distribution) | AddKubernetesEnvironment("k8s") + WithHelm |
kubernetes |
Helm chart directory | aspire deploy, or helm upgrade --install |
| Azure (shared cluster, portable default) | an existing AKS cluster is a Kubernetes target | kubernetes |
Helm chart | aspire deploy against the AKS kubectl context |
| Azure Container Apps (Azure-only) | AddAzureContainerAppEnvironment("aca-env") |
aca |
Bicep (main.bicep + one module per resource) + efmigrations/ |
aspire deploy into the az login subscription |
| Azure Container Apps + Neon | the same aca-env, no Flexible Server |
aca-neon |
Bicep + efmigrations/ |
aspire deploy; Postgres is an external Neon connection string |
One target per publish. Aspire assigns every compute resource to exactly one compute
environment, so Compose, Kubernetes and Azure Container Apps are alternatives selected by configuration, never both in
one model. aca and aca-neon both use the ACA environment; they differ in where Postgres lives.
Publish:Target is read in publish mode only; any other value throws. Run mode
(dev run) always ignores it and keeps the local Postgres container.
Publishing and deploying
aspire publish only writes files — no image build, no deploy, no container runtime needed.
aspire deploy builds images through the detected container runtime and applies them.
# Compose (default target)
dev publish compose # publish to artifacts/aspire-output/compose + safety suite
aspire publish --apphost <apphost.csproj> --output-path out/compose
aspire deploy --apphost <apphost.csproj> # fills .env, builds images, brings the stack up
# Kubernetes (Helm chart)
dev publish kubernetes # publish to artifacts/aspire-output/kubernetes + safety suite + helm lint
aspire publish --apphost <apphost.csproj> --output-path out/k8s -- --Publish:Target=kubernetes
aspire deploy --apphost <apphost.csproj> -- --Publish:Target=kubernetes # helm upgrade --install, current kubectl context
# Azure Container Apps (Bicep) — publishing needs no Azure credentials
dev publish aca # publish to artifacts/aspire-output/aca + safety suite
aspire publish --apphost <apphost.csproj> --output-path out/aca -- --Publish:Target=aca
aspire deploy --apphost <apphost.csproj> -- --Publish:Target=aca # provisions + pushes images, az CLI credential
# Azure Container Apps + Neon — publishing needs no Neon or Azure credentials
dev publish aca-neon # publish to artifacts/aspire-output/aca-neon + safety suite
aspire publish --apphost <apphost.csproj> --output-path out/aca-neon -- --Publish:Target=aca-neon
# Every target — what CI runs
dev publish all # all four publishes, then one safety-suite run + helm lint
- Kubernetes prerequisites: Helm ≥ 4.2, a kubectl context pointing at the cluster, a
container registry the cluster can pull from (
registry-endpoint+registry-repositoryparameters), and an ingress controller already installed in the cluster. - Generated output is never committed.
dev publishwrites underartifacts/(git-ignored); CI uploads the output as a workflow artifact. Regenerate, do not hand-edit. dev publish <target>is the gate. It runs the target's production-safety suite in aspire-tests against the generated files. Run it after any change to publish-mode wiring.dev publish allpublishes every target and checks them in one aspire-tests run.- Deploying is a deliberate, operator-run action — never automated in CI. CI publishes and
runs the production-safety suites only; it never runs
aspire deploy,helm upgradeordocker compose upagainst a real environment. A deploy is run by an operator who has chosen the target, the context and the parameter values, withdev deploy(below).
Aspire CLI version
The installed aspire CLI must match <AspireVersion> in Directory.Packages.props. The AppHost SDK, the Aspire.* pins, and the CI Aspire.Cli install read it. dev run, dev publish, and dev deploy warn when the CLI is older and print dotnet tool update -g Aspire.Cli. A CLI below 13.6 is still refused. The same or a newer CLI is left alone.
Deploying
The first deploy is one command. It publishes (so the migrations bundle exists), deploys, migrates
when the app has a database, smokes the ingress, and opens the app in the browser. --no-browser
prints the URL and opens nothing. With no terminal, or no opener on PATH (wslview, then
explorer.exe on WSL), it prints the URL and still succeeds. --yes skips the prompt only; it
does not change the browser. Kubernetes with no external address does not keep a port-forward: it
prints the dev open --target kubernetes hint. It stops at the first failure and names the verb
to re-run. No CI job, workflow step or dev workflow mode calls it, and none may. A merge
never deploys.
dev deploy # compose: publish, deploy, migrate, smoke, open the app
dev deploy --target kubernetes # same path; opens a LoadBalancer address; otherwise prints the dev open hint
dev deploy --target aca # same path; Azure Container Apps + Flexible Server; opens the ingress (az login first)
dev deploy --target aca-neon # same path; ACA (min replicas 0) + Neon; opens the ingress
dev deploy --target compose --yes # no prompt; aspire deploy --non-interactive; still opens the app
dev deploy --no-browser # print the URL and open nothing
Set Azure:Location and Azure:ResourceGroup (AppHost user secrets, or Azure__Location /
Azure__ResourceGroup) before an Azure deploy so Aspire does not prompt and smoke can read the
ingress host. Put the app and the Neon project in the same region, near the users.
dev deploy --target aca-neon warns when the pooled host's AWS region is far from Azure:Location
and names a nearby Azure region (ap-southeast-1 → southeastasia). A location in that AWS
region's nearby set (for example us-east-1 with eastus or eastus2) stays quiet. The warning
does not print the connection string and does not stop the deploy.
Smoke is GET /web-server/alive and GET /api/identity/sign-in-methods. It retries a cold start
(a Neon wake-up or a scale-to-zero replica). It does not request /api/health. A target with no
platform/postgres/migrations folder beside the AppHost skips migrate and says so.
Operator steps
dev publish, dev deploy migrate, dev open, and dev deprovision stay for one step.
dev publish is what CI runs: the file publish plus the production-safety suite.
dev publish compose # files plus the safety suite (CI)
dev deploy migrate --target kubernetes # migrate only; publishes the bundle when it is missing
dev deploy migrate --target aca-neon # the bundle, on the direct Neon connection (no firewall rule)
dev open --target kubernetes # port-forward the ingress controller and open the browser
dev deprovision --target kubernetes # preflight, then aspire destroy asks before deleting
dev deprovision --target kubernetes --yes # aspire destroy --yes --non-interactive — deletes the deployment and its data
dev deprovision --target aca # aspire destroy, then purge the soft-deleted Key Vault
dev deprovision --target aca-neon # aspire destroy the resource group; the Neon project stays
dev deployruns publish, thenaspire deploy --apphost <csproj> --environment Production -- --Publish:Target=<target> --Parameters:<name>=<value> …, then migrate when the app has a database, then smoke, then opens the ingress the waydev opendoes.--no-browserprints the URL and opens nothing. It forwards the target's deploy parameters (below) after the preflight (below). It asks for confirmation before anything runs;--yesskips the prompt and adds--non-interactiveonaspire deploy. Without a terminal and without--yesit refuses. The deploy step runs Aspire attached to the terminal, so a prompt it still shows (e.g. aca's location and resource group) works. For aca and aca-neon the preflight requiresaz loginand prints the subscription and where it came from, in this order: theAzure__SubscriptionIdenvironment variable, then the AppHost user secretAzure:SubscriptionId(read withdotnet user-secrets list --project <apphost>), then the oneaz account showreports.aspire deployruns as Production and does not load user secrets, so a user-secret subscription is copied toAzure__SubscriptionId. The az CLI value is copied only when neither the environment variable nor the user secret is set, so it never overrides a subscription you pinned. An environment variable is inherited and not rewritten. A subscription Aspire remembered in its own deployment state is not checked; pin it in user secrets ifaz accountmay point elsewhere.Azure:LocationandAzure:ResourceGroupare copied toAzure__LocationandAzure__ResourceGroupthe same way when those variables are unset; otherwise Aspire prompts.Deploy configuration is committed in the AppHost
appsettings.jsonParameterssection. The kubernetes target needsk8s-namespace,helm-release-name,registry-endpointandregistry-repository(the AppHost parameters without a default in code); compose, aca and aca-neon forward none of those on the command line. aca-neon still requiresneon-pooled-connection-stringandneon-direct-connection-stringas secrets (AppHost user secrets orParameters__environment variables). They are not printed and not put on the aspire command line. Production does not load user secrets, sodev deploycopies a user-secret value into the aspire process environment when that variable is unset. A copy in appsettings is refused. The template sets the three that identify the app —k8s-namespace,helm-release-name,registry-repository— to the app's kebab name (a DNS-1123 label:Contoso.Shop→contoso-shop), andregistry-endpointtolocalhost:5001, the kind recipe's registry, so a kind deploy needs no configuration. It also commits the app'singress-port: the Compose host port and the local portdev openforwards, one number per app on every target.dotnet newpicks it when the app is generated (a free port in 20000–60000), so two generated apps do not fight over one port, and nothing defaults to a shared port such as 8080:"Parameters": { "k8s-namespace": "contoso-shop", "helm-release-name": "contoso-shop", "registry-endpoint": "localhost:5001", "registry-repository": "contoso-shop", "ingress-port": "41873" }A value that differs per machine or target overrides the committed one in the AppHost user secrets — typically
registry-endpointfor AKS, an Azure Container Registry login server (pwsh):dotnet user-secrets set 'Parameters:registry-endpoint' 'myregistry.azurecr.io' --project <apphost.csproj>or for one session with a
Parameters__<name>environment variable (${env:Parameters__registry-endpoint} = 'myregistry.azurecr.io'; the name is matched case-insensitively).dev deployresolves each in the order Aspire's configuration does — environment variable, then user secret, thenappsettings.Production.json(none ships), thenappsettings.json— and the plan prints each value and that source. A user secret left over for a committed value keeps winning; remove it withdotnet user-secrets remove 'Parameters:<name>' --project <apphost.csproj>. The values appear in theaspirecommand line, so a forwarded parameter is never a secret — secrets (postgres-password, the Entra client secret, the Neon connection strings) stay off the command line. Production does not load user secrets, sodev deploycopies a user-secret value into the aspire environment when that variable is unset. Never commit a secret inappsettings.json.Preflight runs before
aspireand reports every problem at once, then exits non-zero with nothing run: Aspire CLI ≥ 13.6, and a warning when that CLI is older than<AspireVersion>(see Aspire CLI version); for kubernetes, Helm ≥ 4.2, a current kubectl context (printed — check it) whose API answers (kubectl get --raw /version), every required parameter set (each missing one is listed with the command that sets it), and for a kind context (kind-<cluster>) thatkind get clusterslists the cluster and the registry atregistry-endpointanswers its/v2/API. The API and registry checks give up after 5 seconds and every other probe after 20 (e.g. a credential plugin waiting for a login), reported as timed out; if a parameter is missing anddotnet user-secrets listfailed, the report says the secrets could not be read.Any kubectl context works — AKS, an on-prem cluster, or a local kind cluster.
dev deploynever creates a cluster, installs an ingress controller or switches context.dev deploy migrateapplies the published idempotent migrations for one target, publishing the bundle when it is missing, and reports what it applied. Details, the stale-script check, and the report format: deploy-migrate.md.dev openopens the deployed app in the browser (--no-browserprints the URL; with no opener on PATH it prints it too — on WSL it useswslview, thenexplorer.exe). kubernetes: if the ingress controller's Service has an external (LoadBalancer) address, it opens that; otherwise it runskubectl port-forward --namespace ingress-nginx service/ingress-nginx-controller <ingress-port>:80in the foreground, openshttp://localhost:<ingress-port>, and Ctrl+C stops the forward. The port is the app'singress-portparameter, resolved likedev deploy's parameters (env, user secret,appsettings.Production.json,appsettings.json).--portpicks another local port (a taken one is refused with that hint);--controller-namespace/--controller-servicename a controller other than the kind recipe's. compose:http://localhost:<port>from--port, elseINGRESS_PORTin the published.env, else theingress-portparameter. With no--portand noingress-portanywhere,dev openrefuses rather than guess a port. aca and aca-neon:https://<fqdn>of theingresscontainer app (az containerapp show --name ingress --resource-group <rg> --query properties.configuration.ingress.fqdn). Passkeys: the deploy adds the public ingress host toWebAuthnOptions:AllowedRpIds; a custom domain ispasskey-rp-host. See passkey-hosts.md.aca and aca-neon resource group for
dev open, and fordev deploy migrate --target aca:--resource-group, elseAzure__ResourceGroup, else the AppHost user secretAzure:ResourceGroup— the valuesdev deployuses; the subscription comes from the same preflight asdev deploy.dev deprovisionrunsaspire destroyfor the same target after the same preflight, minus the registry check (for kubernetes it prints the kubectl context first). Deploy parameters are optional there: each one that is set is forwarded the same way (--Parameters:<name>=<value>), and a missing one is never refused. It deletes the deployment's data (Compose volumes, the Kubernetes postgres claim), so Aspire asks for confirmation;--yesskips the prompt. Without a terminal and without--yesit refuses.aspire destroyis local. It only knows deployments thataspire deployrecorded on the machine — and from the checkout — that deployed. When it fails,dev deprovisionprints the manual removal for the target and exits with Aspire's exit code:<runtime> compose down --volumesfor the Compose project (<runtime> compose lsfinds it), orhelm uninstall <release> --namespace <namespace>(the AppHost'shelm-release-nameandk8s-namespaceparameters) plus deleting thepostgres-dataPersistentVolumeClaim, or for acaaz group delete --name <resource-group>(az asks for confirmation) plus the Key Vault purge below. aca-neon uses the sameaz group deleteand does not purge a Key Vault; the Neon project is not in the group. It never falls back to a destructive command on its own.Runtime: Compose deploy and teardown go through Aspire, so
ASPIRE_CONTAINER_RUNTIMEpicks the runtime; the verbs call no container CLI themselves (the registry check is an HTTP request).Without the
devCLI: see without-the-dev-cli.md.
Local Kubernetes with kind
A kind cluster is just another kubectl context: give it a local registry the nodes can pull from,
install ingress-nginx once as cluster infrastructure, then dev deploy --target kubernetes. The full
pwsh and bash recipe (registry, cluster, node registry mapping, ingress, deploy, tear down) is in
local-kubernetes-with-kind.md.
Production-safety rules
These never appear in published output. Each is enforced by the target's aspire-tests suite — extend the suite when you add a new publish-mode branch.
| Never ships | Why | How it is kept out |
|---|---|---|
Mock authentication (Authentication__UseMock) |
it signs requests in as a fake principal | forwarded in run mode only; the server also fail-closes outside Development/Testing |
| Browser-log forwarding | ships client telemetry to a dev dashboard | Development-only; publish runs as Production |
Dashboard Postgres REPL (WithRepl) |
an authenticated psql shell for anyone with dashboard access | Development-only |
TimeWarp.State DevTools inspector (timewarp-devtools, TIMEWARP_STATE_DEVTOOLS_ENDPOINT, its CORS origin variables) |
an unauthenticated UI showing every action and state snapshot of web-server and the browser | AddTimeWarpStateDevTools() / WithTimeWarpStateDevTools() and the ingress CORS origins run in the AppHost's IsRunMode block only. web-server exports spans and maps /_timewarp/state-devtools only in Development with the endpoint set. The browser exporter (TimeWarp.State.DevTools.Wasm) is a Debug-only reference and a Debug-only call, so no Release build or published WASM bundle contains it. In dev run the dashboard links it as TimeWarp DevTools |
SigNoz dashboard link (signoz) |
an operator-chosen URL; committing one would point every generated app at one host | Run mode only, and only when Observability:SigNoz:Url is an absolute https URL. Unset adds nothing. Any other value fails AppHost startup and names the key. AddExternalService also excludes it from the manifest. In dev run the dashboard links it as SigNoz. This does not export telemetry |
| Aspire dashboard in the deployment | a second, unauthenticated UI and port | WithDashboard(false) on every environment — point OTEL_EXPORTER_OTLP_ENDPOINT at your own collector. ACA deploys it as a public dotNetComponents resource unless disabled |
| Any host port / externally reachable service besides the ingress | every extra exposure is an unaudited entry point | Compose: only the ingress publishes a port (ingress-port). Kubernetes: every Service is ClusterIP; the cluster Ingress is the only way in. ACA: only the ingress container app has external: true; web, api and grpc are internal |
| Secret literals | literals end up in images, repos and logs | secrets are parameters (below) |
| Debug/Trace logging, EF Core SQL, sensitive-data logging | per-query SQL and parameter values fill disks and leak data | every host's base appsettings.json is Default: Information with EF Core (and .Database.Command), HTTP client, Polly, YARP and gRPC at Warning; only appsettings.Development.json adds Debug, for the app's own namespaces. EnableSensitiveDataLogging is gated on IsDevelopment(). A guard test checks the committed files; the publish suites reject any Logging__LogLevel__* at Debug/Trace |
To see EF Core SQL locally, opt in per machine instead of committing a level:
dotnet user-secrets set "Logging:LogLevel:Microsoft.EntityFrameworkCore.Database.Command" "Information"
in the web-server project, or set Logging__LogLevel__Microsoft.EntityFrameworkCore.Database.Command=Information
in the environment. Remove it when done; dev run logs grow without bound.
Rules for new code:
- Gate publish-only behavior on
builder.ExecutionContext.IsPublishMode/IsRunMode, never on a template flag — every flag combination must publish. - Anything dev-convenient (REPL, mock auth, log forwarding, State DevTools, the SigNoz link, dashboard commands) is run-mode or Development-only. Publish runs as Production.
- Without the
yarpflag there is no ingress: the published output exposes nothing, and the operator adds their own edge.
SigNoz link on the local dashboard
dev run can show a SigNoz link on the Aspire dashboard resource list. Set Observability:SigNoz:Url to an absolute https URL in the AppHost user secrets, or set Observability__SigNoz__Url for one session. The template does not commit a URL. A missing or blank value adds no resource. A value that is not an absolute https URL fails AppHost startup and names the key. Publish and deploy never include the resource, and the link does not export telemetry.
dotnet user-secrets set "Observability:SigNoz:Url" "https://observability.example" --project source/container-apps/aspire/projects/aspire-app-host/aspire-app-host.csproj
Observability__SigNoz__Url=https://observability.example dev run
Secrets and parameters
Every value that differs per deployment is an AddParameter, never a literal in code; a
non-secret default every machine shares (the app's identity) is committed in the AppHost
appsettings.json Parameters section, not in the AddParameter call. Secrets are
AddParameter(name, secret: true) (or a generated secret such as Postgres' password).
| Target | Where parameter values live |
|---|---|
| Compose | .env beside docker-compose.yaml; aspire deploy / aspire do prepare-compose fill it |
| Kubernetes | values.yaml: secrets under secrets.<resource> (rendered into <resource>-secrets Secret objects, empty defaults), never ConfigMaps |
| Azure Container Apps | @secure() Bicep parameters (no defaults) that become container-app secrets read through secretRef. The Postgres connection string lives in a Key Vault Aspire provisions, which web-server reads with its managed identity; the Postgres password is also on web-server as the container-app secrets postgres-db-password and postgres-db-uri, built from the @secure() parameter |
| Azure Container Apps + Neon | two @secure() parameters, neon-pooled-connection-string and neon-direct-connection-string, with no defaults. web-server reads the pooled string as ConnectionStrings__postgres-db. The migration bundle uses the direct string. dev deploy does not put either value on the command line or in the plan. Production does not load user secrets, so a user-secret value is copied into the aspire process environment. Set them in AppHost user secrets or Parameters__ environment variables, never in appsettings |
- Non-secret deploy configuration that names the app is committed in the AppHost
appsettings.jsonParameterssection (see Deploying). Per-machine values and secrets go in AppHost user secretsParameters:<name>orParameters__<name>environment variables, which override the committed value.dev deployrefuses until the target's required ones resolve and forwards them to Aspire; interactiveaspire deployprompts for any other unset parameter. - Parameters such as
ingress-class,postgres-storage-capacityandhelm-chart-versionare baked into the chart at publish time; change them by re-publishing, nothelm --set. - Under a plain
helm install(noaspire deploy), the Postgres password appears under two keys —secrets.postgres.postgres_passwordandsecrets.web_server.postgres_password— and both must carry the same value.aspire deployfills both from the one parameter. - Entra settings (
entra-tenant-id,entra-client-id,entra-client-secret,entra-public-origin) are parameters.entra-enabledpublishes asSignInOptions__IncludeMicrosoft365(${ENTRA_ENABLED}on Compose, the Helm value, or the Azure Container Apps parameter). True appendsMicrosoft365to the checked-inSignInOptions:Methodslist and does not replace index 0. A passkey-only deployment needs none of the Entra parameters. Every published target uses the placeholderunusedwhenParameters:entra-client-secretis unset.AddParameter(name, value, secret: true)ignores configuration, and Azure Container Apps rejects an empty container-app secret. With Entra enabled and the secret stillunused, sign-in fails with AADSTSinvalid_client. Set the real secret before turning Entra on.
Postgres and migrations per target
Migrations are explicit in every deployed environment: the AppHost never auto-migrates a
deployment. web-server does not migrate at startup and tolerates a not-yet-migrated database.
The published idempotent SQL script (efmigrations/web-migrations.sql) is safe to re-run.
Apply them with dev deploy migrate --target <target> (Deploying above). The last column is
what it runs — run it yourself in a generated app without the dev CLI (<runtime> is docker
or podman; dev deploy migrate passes the running project's --project-name and --file from
<runtime> compose ls):
| Target | Storage | Apply migrations (what dev deploy migrate runs) |
|---|---|---|
| Compose | named volume postgres-data; POSTGRES_DB creates the database on first start |
<runtime> compose exec -T postgres sh -c 'PGPASSWORD="$POSTGRES_PASSWORD" psql -U postgres -d postgres-db -v ON_ERROR_STOP=1' < efmigrations/web-migrations.sql |
| Kubernetes | postgres-data PersistentVolumeClaim (postgres-storage-capacity, default 10Gi), single-replica StatefulSet |
kubectl exec -i -n <namespace> statefulset/postgres-statefulset -- sh -c 'PGPASSWORD="$POSTGRES_PASSWORD" psql -U postgres -d postgres-db -v ON_ERROR_STOP=1' < efmigrations/web-migrations.sql |
| Azure Container Apps | Azure Database for PostgreSQL Flexible Server (managed storage and backups); the Bicep creates postgres-db |
the published bundle from the operator's machine, through a temporary firewall rule — see Azure Container Apps below |
| Azure Container Apps + Neon | Neon Postgres (external). The app uses the pooled host; migrations use the direct host | the published bundle with the direct connection string — see Azure Container Apps + Neon below |
The script is piped on stdin (< efmigrations/web-migrations.sql in bash; in pwsh
Get-Content -Raw efmigrations/web-migrations.sql | <command>). dev deploy migrate adds -q and
PGOPTIONS='-c client_min_messages=warning' unless --verbose, and reads
psql -At -c 'SELECT "MigrationId" FROM "__EFMigrationsHistory" ORDER BY "MigrationId"' before and
after for its report.
- Run the script after the database is up and before (or right after) the app starts serving.
- Compose also publishes the self-contained migration bundle; it is a host binary, not an image, so the SQL script is the default path. The Helm chart carries the script only — Helm rejects chart files over 5 MiB.
-T/-iwithPGPASSWORDfrom the container's own environment is required: the image enforces password auth even on the in-container socket, and a piped session cannot prompt.- Feedback attachment bytes live in Azure Blob Storage when
FeedbackAttachments__ConnectionStringis set, otherwise in Postgres (feedback.feedback_attachment_bytes, backed up with the database), and in process memory only in apps generated withoutpostgres(lost on restart).
Data Protection key ring
ASP.NET Core Data Protection encrypts auth cookies and other protected payloads. Every replica of one app must share one key ring, and the ring must outlive a container.
Agent access tokens (IAgentTokenStore) are in memory on every host, even when postgres is on: a restart or a second instance invalidates live tokens, and the reviewer reissues with its key.
| postgres | Where the ring lives |
|---|---|
| on, and a connection string is set | Postgres table data_protection.keys, via PersistKeysToDbContext on PostgresDbContext. The application name is the template source name (TimeWarp.Architecture here; dotnet new rewrites it to the generated app's name), so every replica of that app shares keys and two apps do not. dev deploy migrate creates the table with the other migrations. |
| off, or no connection string | The ASP.NET default file-system ring, inside the container. No volume is mounted. A new container, a second replica, or a scale-to-zero cold start gets an empty ring. Cookies and other protected payloads from the previous process stop validating. Turn postgres on when sign-in must survive a restart. |
The ring is not wrapped with a certificate or Azure Key Vault. Compose has nowhere to put that protector. aca provisions a Key Vault for the Postgres connection string, not for this ring. aca-neon provisions no Key Vault. The database's own encryption is the at-rest protection for the key XML. A certificate or Key Vault protector is a possible follow-up.
Targets with postgres (compose, kubernetes, aca, aca-neon) all use the same table. aca-neon sets min replicas to 0, so the container disk is empty after idle; the Postgres ring is what keeps a signed-in cookie valid across that cold start.
Ask uses XAI:ApiKey when that value is set (environment variable XAI__ApiKey, a container-app secret, or a Development user secret). The host value wins, and Admin → AI is read-only. When postgres is on and a connection string is set, an administrator can set the key on Admin → AI instead. The plaintext is protected with this ring (purpose TimeWarp.Architecture.XaiApiKey, rewritten with the generated app's name) and stored in secrets.protected_secrets. The browser receives a status, never the key. Ask reads it on each turn. Without postgres, or with no connection string, Admin → AI only shows how to set the host value. When the host key is unset, Ask uses the signed-in user's key or the site key according to the site BYOK policy (Required, Allow, or Off on Admin → AI). That select is read-only when the host key is set.
Ingress topology
All public traffic enters through the YARP ingress, which owns the routing table (generated
web /api prefixes, the api catch-all, /grpc prefix strip, and the public-host forwarding for
web routes). Run mode loads that table from the yarp project. Publish mode (Compose, Kubernetes,
Azure Container Apps) loads the same table from the AppHost onto the AddYarp image.
Client-facing scheme and host. On web-server routes YARP sets
X-Forwarded-ProtoandX-Forwarded-Hostfrom the request it is proxying, overwriting anything the client sent web-server. Run mode (and the standalone yarp project) runsUseTrustedProxyForwardedHeadersfirst, so those values are the ones a trusted proxy sent. The defaultTrustedProxylist is loopback (127.0.0.1and::1), which is Caddy on the same machine;dev runneeds no extra setting. An empty list does not trust everyone — the headers are ignored. A proxy that is not on loopback setsTrustedProxy:KnownNetworksto its CIDR (orKnownProxiesto its address) in the yarp appsettings. The pinned http port is bound by the yarp process itself, so no extra hop rewritesX-Forwarded-Protoback tohttp. Publish mode keeps the AddYarp image, which does not run that middleware; give that deployment a proxy whose hop to YARP is already the public scheme, or run the yarp project and setKnownNetworks. web-server readsX-Forwarded-Hostonly to select the passkey RP ID fromWebAuthn:AllowedRpIdsand does not callUseForwardedHeaders. Link-preview tags and mail permalinks read the same headers for the absolute origin (SiteMetadata:BaseUrlstill wins for tags when it is set).Compose: the ingress is the only service with a host port. Put TLS in front of it (your reverse proxy or load balancer).
Azure Container Apps: the ingress container app is the only one with external ingress (ACA terminates HTTPS on its public FQDN); web, api and grpc have internal ingress only.
Kubernetes: the chart carries one
networking.k8s.ioIngress (cluster-ingress) whose default backend is the YARP ingress' http endpoint. TLS terminates at the cluster's ingress controller. The class is theingress-classparameter (defaultnginx).The chart does not install an ingress controller. A controller is cluster-scoped infrastructure; an app chart that installs one collides with every other release. Install one per cluster.
Do not replace YARP with per-service controller routes. That forks the routing table into a second implementation per target and loses the
X-Forwarded-Hostoverwrite and the/grpcprefix strip, which every controller vendor expresses differently.Behind any proxy that terminates TLS, set
Authentication:Entra:PublicOriginon web-server explicitly when Entra is on; it is not derived from the ingress URL.
Azure
An existing AKS cluster is a Kubernetes target: point the kubectl context at it, use the
cluster's registry (for example an Azure Container Registry) as registry-endpoint, choose the
controller's class as ingress-class, and run the Kubernetes commands above. The Kubernetes
target uses nothing Azure-specific, so the same chart runs on any cluster.
- Do not use
AddAzureKubernetesEnvironment. It provisions and owns the cluster (aspire destroydeletes it), ties cluster lifecycle to one app, and its documented ingress path depends on preview features. Share an existing cluster instead. - Do not host Postgres data on ACA container volumes. They are Azure Files (SMB) shares; a database belongs on a managed Postgres service there.
- Adding any Azure-provisioning environment is a new
Publish:Targetvalue with its own production-safety suite — follow the same pattern as the existing targets, never a second environment beside them.
Azure Container Apps (Publish:Target=aca)
Choose ACA for a small or mostly idle app with no cluster to share; choose AKS (the Kubernetes
target) when a cluster exists, is shared, or the deployment must stay portable. The publish-only
AppHost provisions a Container Apps environment (no dashboard), ingress/web/api/grpc container
apps (only the ingress external) and an Azure Database for PostgreSQL Flexible Server whose firewall
rule is AllowAllAzureIps (the admin password is the barrier; aca-publish-tests pins the rule).
The first deploy is dev deploy --target aca (publish, deploy, migrate, smoke, open the app; --no-browser prints the URL).
dev deploy migrate --target aca --resource-group <rg> and dev open --target aca --resource-group <rg>
are the one-step verbs. Remove it with dev deprovision --target aca.
Cost model, what the AppHost provisions, the deploy commands, the migration bundle by hand (firewall rule, connection string), where the Postgres credentials live, expected deploy problems (slow first deploy, "Server is busy", soft-deleted Key Vault names, web hop host) and deprovision detail: azure-container-apps.md.
Azure Container Apps + Neon (Publish:Target=aca-neon)
Same ACA publisher as aca, without Flexible Server and without the postgres Key Vault. Postgres is
Neon. The operator guide (create the project, set the two secrets, one-command deploy, region, tear down,
and the ACR Basic cost exception) is azure-container-apps-neon.md.
dev deprovision --target aca-neon deletes the Azure resource group only. It does not delete the Neon project.
Container-runtime neutrality
- Generated Compose output is a standard compose file: Docker Compose, Podman Compose, or any compliant runtime runs it.
- Aspire picks the runtime it detects;
ASPIRE_CONTAINER_RUNTIMEoverrides it (docker,podman). Tooling must go through Aspire's runtime selection — never hard-code thedockerCLI in scripts or dev commands. aspire publishneeds no runtime at all, so publish gates run anywhere; onlyaspire deployand image builds need one. New runtimes (for example WSL containers) become usable when Aspire supports them, with no AppHost change.
Related
- AppHost Design regions — per-decision reasoning behind every rule above:
publish-target.cs(targets and their posture),postgres-resources.cs(database and migrations),ingress-resource.cs(ingress ports, routes, forwarding),web-server-resource.cs(Entra parameters, run-mode tooling). tools/dev-cli/endpoints/deploy-command.cs/deprovision-command.cs—dev deploy/dev deprovision; their Design regions record the preflight and theaspire destroyhand-off.tools/dev-cli/endpoints/deploy-migrate-command.cs/open-command.cs—dev deploy migrate/dev open;services/deploy-browser.csis the opener both verbs use;services/deploy/deploy-operate.csrecords that a missing migrations artifact is published (files only) and then applied, how the Compose project is found, and the firewall-rule cleanup.- aspire-tests
compose-publish-tests/kubernetes-publish-tests/aca-publish-tests— the production-safety suites.aca-neon-publish-testsguards the Neon target.