At a glance
| What | Value |
|---|---|
| Good for | Teams that already run on Azure and want managed containers and a managed database |
| Time to deploy | About 20 minutes, most of it waiting for the database |
| Cost | From $76.53/month in East US (see below) |
The Terraform passes validation and parts of it were run locally, but a full apply against a real Azure subscription has not been run yet. The Tested section below lists what was and was not checked.
What this sets up
- A resource group and a virtual network with two delegated subnets: one for the Container Apps environment, one for the database. Nothing else runs in it, so only Palace and the setup job can reach the database.
- Azure Database for PostgreSQL Flexible Server 17 (Burstable B1ms by default) with private access only: no public endpoint, its name resolves to a private address through a private DNS zone. TLS is required, 7 days of backups and point-in-time recovery, and a delete lock on the server.
vectorandpgcryptoare allow-listed. Palace connects aspalace_appover TLS (sslmode=verify-fullagainst the public CAs in the Palace image), and that role cannot bypass row-level security. - Azure Container Apps (Consumption profile) in the virtual network: two replicas that never scale to zero (the embedding worker runs inside Palace), at most three. Each replica runs Palace Server as UID 10001 (0.5 vCPU, 1 GiB) and an nginx proxy sidecar (0.25 vCPU, 0.5 GiB, non-root). Health probes on
/healthzand/readyz. - HTTPS ingress to the proxy only, with a free managed certificate for your domain, HTTP to HTTPS redirect and HSTS. The proxy returns 404 for
/metricsand for/bootstrapunless the request carries the bootstrap token and bootstrap is enabled. Palace's port 8080 is not exposed. - Key Vault (RBAC) for the license key, JWT secret, bootstrap token, database passwords and the full database URL. Container Apps reads them with managed identities; Palace's identity can read only its four secrets, the setup job's identity only the two database passwords.
- A Container Apps job that prepares the database once, started by hand.
- Log Analytics with 30 days of retention, and the CNAME and TXT records in your Azure DNS zone (optional).
Costs
Prices checked 2026-11-29, USD per month (730 hours) before tax, read from the Azure Retail Prices API ↗ (pay-as-you-go retail prices) that feeds these pages: Container Apps ↗, PostgreSQL Flexible Server ↗, Load Balancer ↗, Public IP addresses ↗, Azure DNS ↗, Key Vault ↗, Log Analytics ↗. The managed certificate is free.
Small (default): 2 replicas of 0.75 vCPU / 1.5 GiB (Palace plus proxy), B_Standard_B1ms, 32 GB. Medium: 2 replicas of 1.25 vCPU / 2.5 GiB (palace_cpu = 1, palace_memory = "2Gi"), B_Standard_B2s, 64 GB.
| Line | Small East US | Small Germany West Central | Medium East US | Medium Germany West Central |
|---|---|---|---|---|
| Container Apps vCPU (idle rate, after free grant) | $11.29 | $11.29 | $19.17 | $19.17 |
| Container Apps memory (after free grant) | $22.57 | $22.57 | $38.34 | $38.34 |
| PostgreSQL compute | $12.41 | $14.53 | $49.64 | $58.11 |
| PostgreSQL storage | $3.68 | $4.38 | $7.36 | $8.77 |
| Load balancer of the environment | $18.25 | $18.25 | $18.25 | $18.25 |
| Public IPv4 (ingress + egress) | $7.30 | $7.30 | $7.30 | $7.30 |
| Private DNS zone (database) | $0.50 | $0.50 | $0.50 | $0.50 |
| Public DNS zone | $0.50 | $0.50 | $0.50 | $0.50 |
| Key Vault operations (under 10,000 assumed) | $0.03 | $0.03 | $0.03 | $0.03 |
| Log Analytics (1 GB / 5 GB assumed, within the free 5 GB) | $0.00 | $0.00 | $0.00 | $0.00 |
| Total | $76.53 | $79.35 | $141.09 | $150.97 |
| Total if replicas never count as idle | $155.53 | $158.35 | $275.28 | $285.16 |
Rates used (East US / Germany West Central):
| Item | East US | Germany West Central |
|---|---|---|
| Container Apps vCPU-second, active / idle | $0.000024 / $0.000003 | $0.000024 / $0.000003 |
| Container Apps GiB-second, active and idle | $0.000003 | $0.000003 |
| Container Apps requests per million (2 million free) | $0.40 | $0.40 |
PostgreSQL B1ms per hour | $0.017 | $0.0199 |
PostgreSQL B2s per hour | $0.068 | $0.0796 |
| PostgreSQL storage per GB-month | $0.115 | $0.137 |
| PostgreSQL backup storage (LRS) per GB-month | $0.095 | $0.103 |
| Standard load balancer per hour (first 5 rules) / per GB processed | $0.025 / $0.005 | $0.025 / $0.005 |
| Standard static public IPv4 per hour | $0.005 | $0.005 |
| Azure DNS zone per month (first 25) | $0.50 | $0.50 |
| Key Vault operations per 10,000 | $0.03 | $0.03 |
| Log Analytics ingestion per GB after 5 GB free | $2.30 | $2.99 |
How the Container Apps lines are worked out: each month every subscription gets 180,000 vCPU-seconds and 360,000 GiB-seconds free (billing ↗). A replica at its minimum count is billed at the idle vCPU rate while it handles no requests, uses under 0.01 vCPU and receives under 1,000 bytes per second; memory costs the same either way. The table assumes the replicas are idle all month, which is the lower bound. Every second a replica serves requests is billed at the active rate (8 times higher for vCPU), so a busy team lands between the two total rows. Whether Palace's background embedding worker keeps a replica below the idle thresholds has not been measured.
An environment in your own virtual network comes with a standard load balancer and two public IPs that Azure bills to you (networking ↗); they are about a third of the small bill and do not grow with your team. The load balancer line assumes Azure uses at most 5 rules. Not included: data transfer out, load balancer data processed, backup storage beyond what Azure includes, reservations and savings plans. Skip the public DNS zone line if you already pay for it. Your Palace license is billed separately.
Steps
Prepare
- The Azure CLI, logged in (
az login) to the target subscription, withOwnerorContributorplusUser Access Administratoron it (Terraform creates role assignments). - A public Azure DNS zone that contains your domain, for example
yourco.comforpalace.yourco.com. Or setmanage_dns = falseand create two records at your DNS provider (see step 3). - A license key from palacememory.com.
- Terraform 1.6+ or OpenTofu.
Configure
git clone https://github.com/AncientiCe/palace-server-examples.git
cd palace-server-examples/azure
cp terraform.tfvars.example terraform.tfvars # edit it
export TF_VAR_license_key='your-license-key'
export ARM_SUBSCRIPTION_ID="$(az account show --query id -o tsv)"Terraform state holds the generated secrets (database passwords, JWT secret, bootstrap token). For anything beyond a trial, keep state in an encrypted remote backend such as a private Azure Storage container.
Deploy
terraform init
terraform applyWith manage_dns = false the first apply stops short of the custom domain. Create the two records it prints, then add the domain:
terraform output dns_records # a CNAME and an asuid TXT record
# in terraform.tfvars: dns_records_ready = true
terraform applyPrepare the database once. This starts a short job as the server administrator: it creates the vector and pgcrypto extensions and the palace_app role (db-setup.sh ↗), and is safe to run again.
eval "$(terraform output -raw db_setup_command)"
eval "$(terraform output -raw db_setup_status_command)" # repeat until SucceededThe job log is under the job's Execution history in the portal and ends with Database ready for Palace. Until the setup has run, Palace cannot log in to the database and Container Apps keeps restarting it; that is expected.
Then issue and bind the free certificate for your domain. Azure checks the DNS records and needs a few minutes; renewals happen on their own.
eval "$(terraform output -raw bind_certificate_command)"https://<your domain>/readyz then returns 200. Terraform ignores the certificate binding from now on, so later applies leave it alone.
Create the first admin
Bootstrap runs from your machine through the proxy, which forwards /bootstrap only with the right X-Bootstrap-Token header.
terraform output -raw bootstrap_command # edit the three values, then run itSave the api_key and org_id. Then turn bootstrap off, which removes the token from Palace and the proxy:
# in terraform.tfvars
enable_bootstrap = false
terraform applyAfter that the token does nothing anyway, because bootstrap works only once.
Connect your team
Follow Connect clients with your URL.
Upgrade
Set the new tag and apply. Container Apps starts a new revision and moves traffic to it once its replicas pass the readiness probe; the old revision keeps serving until then.
# in terraform.tfvars
palace_version = "<new version>"
terraform applyRestore
Flexible Server restores a point in time to a new server (guide ↗). Restore into the same virtual network and private DNS zone, put the new server name in the database-url secret in Key Vault, then restart the active revision so Palace reads it (az containerapp revision list shows its name, az containerapp revision restart --revision <name> restarts it). Terraform still tracks the old server; bring the code in line before your next apply.
Tested
The Terraform passes terraform fmt -check and terraform validate (Terraform 1.9.8, azurerm provider 4.81.0). The proxy sidecar was run locally with Docker exactly as Container Apps starts it (same image, proxy-entrypoint.sh ↗ and proxy.conf.template ↗), sharing the network namespace of a stand-in upstream on port 8080: /readyz is proxied; /metrics, /metrics/x, //metrics and /%6detrics return 404; POST /bootstrap returns 404 with no header, an empty header or a wrong token and is proxied with the right one; with the token empty or unset, /bootstrap returns 404 whatever the header.
db-setup.sh was run twice against a local pgvector/pgvector:pg17 container from the same postgres:17-alpine image the job uses, as a non-root user with a read-only filesystem and no capabilities: the second run changes nothing, palace_app has rolsuper = f and rolbypassrls = f, and both extensions exist. It was also run as a non-superuser with CREATEDB and CREATEROLE that owns the database (as on Azure), with the extensions created beforehand. The Palace image and the postgres:17-alpine image both contain DigiCert Global Root G2 and Microsoft RSA Root Certificate Authority 2017.
A full apply against a real Azure subscription has not been run yet. Not tested: the Container Apps environment in the virtual network, Key Vault references through managed identities, the managed certificate and its binding, TLS with verify-full against a real Flexible Server, the setup job on Azure (where the administrator is in azure_pg_admin, not a superuser, and CREATE EXTENSION relies on the azure.extensions allow-list), the idle billing of the replicas and the restore steps. If something fails, open an issue ↗.
Troubleshooting
- Palace replicas keep restarting: check that the setup job ran and succeeded, then read the
palace-servercontainer logs under the app's Log stream in the portal. An expired or wrong license stops startup. - Apply fails with 403 on a Key Vault secret: a new role assignment had not reached Key Vault yet. Run
terraform applyagain. - Adding the custom domain fails: the CNAME or
asuidTXT record is missing or not visible yet. Check withnslookup -type=TXT asuid.<domain>and apply again. - The certificate stays pending: the CNAME must point straight at the app's
*.azurecontainerapps.ioname (no proxy such as Cloudflare in front), and a CAA record on your zone must allowdigicert.com. - Setup job cannot pull
postgres:17-alpine: Docker Hub limits anonymous pulls. Copy the image to your own registry and setpsql_image. /bootstrapreturns 404: check the token header and thatenable_bootstrapis still true. After the first admin exists it returns 409.terraform destroyfails on the database: setdb_delete_lock = false, apply, then destroy. Key Vault is soft-deleted for 7 days; reusing the samenamecreates a new vault name anyway.- Something else? Open an issue ↗
Nomad, Hetzner, OpenShift, another IaC tool? Request a setup ↗. Never paste license keys, passwords, tokens or database URLs in an issue.
Other setups
Docker Compose on one machine · DigitalOcean (Terraform) · AWS (Terraform, ECS Fargate + RDS) · Google Cloud (Terraform, Cloud Run + Cloud SQL) · Kubernetes (Helm) · Kubernetes (plain kubectl) · Air-gapped (no internet) · Linux without Docker (systemd)