- Update variables in
var.tf - Set passwords in
terraform.tfvars(see: Generate secure keys) - Clean state if needed:
rm -rf .terraform .terraform.lock.hcl terraform.tfstate terraform.tfstate.backup# Login
az login
az login --use-device-code --tenant <name>.onmicrosoft.com
az account set --subscription <subscriptionID>
# Register provider (first time only)
az provider register --namespace Microsoft.App
# Deploy
terraform init
terraform plan
terraform apply # -auto-approveterraform import azurerm_resource_group.rg /subscriptions//resourceGroups/
| Variable | Description |
|---|---|
subscription-id |
Your Azure subscription ID |
pgsql-password |
PostgreSQL password (no default, required) |
dify-secret-key |
API encryption key |
dify-plugin-daemon-key |
Plugin daemon auth key |
dify-inner-api-key |
Internal API key |
dify-sandbox-api-key |
Sandbox execution key |
Generate secure keys and write them to terraform.tfvars:
cat <<EOF > terraform.tfvars
pgsql-password = "$(openssl rand -base64 24 | tr -d '/+=' | head -c 32)"
dify-secret-key = "$(openssl rand -base64 42)"
dify-plugin-daemon-key = "$(openssl rand -base64 42)"
dify-inner-api-key = "$(openssl rand -base64 42)"
dify-sandbox-api-key = "$(openssl rand -base64 42)"
EOFShould also review:
group-name- Resource group nameregion- Azure regionstorage-account,redis,psql-flexible- Must be globally unique
Deploy Dify (v1.14.0) on Azure using Terraform.
| Component | Azure Service |
|---|---|
| nginx | Container Apps |
| web | Container Apps |
| api | Container Apps |
| worker | Container Apps |
| worker_beat | Container Apps (singleton, scheduled tasks) |
| sandbox | Container Apps |
| ssrf_proxy | Container Apps |
| plugin_daemon | Container Apps |
| db | PostgreSQL Flexible Server |
| redis | Azure Cache for Redis |
| storage | Azure Blob Storage |
- Copy and configure variables:
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your values- Deploy:
terraform init
terraform apply # -auto-approve if # if you are lazy of saying yes everytimeSee PROJECT.md for detailed configuration and troubleshooting.
- Deployment Name (your model deployment, e.g.
gpt-5-mini)3
- API Key
- Azure OpenAI Endpoint
e.g https://.openai.azure.com/openai/v1
Path: Settings → Model Provider → Add Model → Azure OpenAI
| Field | Value |
|---|---|
| Deployment Name | <deployment-name> |
| Model Type | LLM |
| Authorization Name | any |
| API Endpoint URL | https://<resource>.openai.azure.com/openai/v1 |
| API Key | <api-key> |
| API Version | (optional: automatically set on endpoint openai/v1) |
| Base Model | same as deployment name |
- Must use deployment name, not model name
- Endpoint must include
/openai/v1 - API version must match Azure support