> ## Documentation Index
> Fetch the complete documentation index at: https://docs.backtale.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy Backtale on Azure

> Apply the self-contained Azure Terraform pack: Container Apps, PostgreSQL Flexible Server with pgvector, and the public image pinned by digest.

The Azure pack lives at `deploy/terraform/azure` on `main` of the product repository. It is self-contained: copy that folder, or use the copy in your license zip, and run Terraform without the rest of the repository. It creates one Container App (external HTTPS, port 3000) and Azure Database for PostgreSQL Flexible Server with the `vector` extension allow-listed. The image is public `ghcr.io/rahilp/backtale` pinned by digest. Leave registry credentials empty.

This is a first-install shape: one replica, and a firewall rule that allows Azure services. Private networking, Key Vault references, and a custom domain are follow-on work.

## Before apply

* Azure CLI signed in (`az login`) with rights to create a resource group
* Terraform 1.5 or later
* The digest and `cosign.pub` from your order. [Verify the image](https://docs.backtale.app/install/verify.md) before `terraform apply`.

## Apply

**1. Set the digest and the public URL**

```bash theme={null}
cp terraform.tfvars.example terraform.tfvars
```

Set:

```hcl theme={null}
image_digest = "sha256:a4b6216589d14bd4be4deb7db4ed2f81ad28f65b76475135d741bab4c0d8721a"
app_base_url = "https://backtale.example.com"
```

`license_file_path` is a note for you. Terraform does not mount the license file.

**2. Create the resources**

```bash theme={null}
terraform init
terraform plan
terraform apply
```

Leave `database_password`, `token_encryption_key`, and `auth_setup_token` unset so Terraform generates them. After the first apply, set `app_base_url` to `https://` plus the `container_app_fqdn` output (or your custom domain) and apply again so links match the host people use.

**3. Create the vector extension**

As the database admin, on the `backtale` database:

```sql theme={null}
CREATE EXTENSION IF NOT EXISTS vector;
```

**4. Save the encryption key**

```bash theme={null}
terraform output -raw token_encryption_key
```

Store that value outside Azure. Open `https://<fqdn>/setup` with `terraform output -raw auth_setup_token`. Continue with [First run](https://docs.backtale.app/install/first-run.md), then remove `AUTH_SETUP_TOKEN` from the Container App secrets and env and create a new revision.

The container runs migrations on boot. Keep a single replica for that first start. See [Environment](https://docs.backtale.app/install/environment.md).

Probes you can add yourself: liveness `GET /api/health`, readiness `GET /api/health/ready`. Do not restart the replica because readiness failed.

## Upgrade

Back up Flexible Server, [verify](https://docs.backtale.app/install/verify.md) the new digest, set `image_digest`, and `terraform apply`. Read [Upgrade by digest](https://docs.backtale.app/install/upgrade.md) before you change an existing database.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.