On Azure Postgres FelxibleServer
In this guide we show how to deploy EdgeDB on Azure using Postgres FelxibleServer as the backend.
Prerequisites
- Valid Azure Subscription with billing enabled or credits (free trial).
- Azure CLI (install).
Provision an EdgeDB instance
Login to your azure account.
1. az login
Create a new resource group.
1. GROUP=my-group-name
1. az group create --name $GROUP --location westus
Provision a PostgreSQL server.
If you already have a database provisioned you can skip this step.
If you get an error saying Specified server name is already used. change the server name and rerun the command.
1. PG_SERVER_NAME=postgres-for-edgedb
1. read -rsp "Password: " PASSWORD
1. az postgres flexible-server create \
2. --resource-group $GROUP \
3. --name $PG_SERVER_NAME \
4. --location westus \
5. --admin-user edgedb \
6. --admin-password $PASSWORD \
7. --sku-name Standard_D2s_v3 \
8. --version 12 \
9. --yes
Allow other azure services access to the postgres instance.
1. az postgres flexible-server firewall-rule create \
2. --resource-group $GROUP \
3. --name $PG_SERVER_NAME \
4. --rule-name allow-azure-internal \
5. --start-ip-address 0.0.0.0 \
6. --end-ip-address 0.0.0.0
Start an EdgeDB container.
1. PG_HOST=$(
2. az postgres flexible-server list \
3. --resource-group $GROUP \
4. --query "[?name=='$PG_SERVER_NAME'].fullyQualifiedDomainName | [0]" \
5. --output tsv
6. )
1. DSN="postgresql://edgedb:$PASSWORD@$PG_HOST/postgres?sslmode=require"
1. az container create \
2. --resource-group $GROUP \
3. --name edgedb-container-group \
4. --image edgedb/edgedb:nightly \
5. --dns-name-label edgedb \
6. --ports 5656 \
7. --secure-environment-variables \
8. "EDGEDB_SERVER_PASSWORD=$PASSWORD" \
9. "EDGEDB_SERVER_BACKEND_DSN=$DSN" \
10. --environment-variables \
11. EDGEDB_SERVER_TLS_CERT_MODE=generate_self_signed \
Persist the SSL certificate. We have configured EdgeDB to generate a self signed SSL certificate when it starts. However, if the container is restarted a new certificate would be generated. To preserve the certificate across failures or reboots copy the certificate files and use their contents in the EDGEDB_SERVER_TLS_KEY and EDGEDB_SERVER_TLS_CERT environment variables.
1. key="$( az container exec \
2. --resource-group $GROUP \
3. --name edgedb-container-group \
4. --exec-command "cat /etc/ssl/edgedb/edbprivkey.pem" \
5. | tr -d "\r" )"
1. cert="$( az container exec \
2. --resource-group $GROUP \
3. --name edgedb-container-group \
4. --exec-command "cat /etc/ssl/edgedb/edbtlscert.pem" \
5. | tr -d "\r" )"
1. az container delete \
2. --resource-group $GROUP \
3. --name edgedb-container-group \
4. --yes
1. az container create \
2. --resource-group $GROUP \
3. --name edgedb-container-group \
4. --image edgedb/edgedb:nightly \
5. --dns-name-label edgedb \
6. --ports 5656 \
7. --secure-environment-variables \
8. "EDGEDB_SERVER_BACKEND_DSN=$DSN" \
9. "EDGEDB_SERVER_TLS_KEY=$key" \
10. --environment-variables \
11. "EDGEDB_SERVER_TLS_CERT=$cert"
To access the EdgeDB instance you’ve just provisioned on Azure from your local machine link the instance.
1. printf $PASSWORD | edgedb instance link \
2. --password-from-stdin \
3. --non-interactive \
4. --trust-tls-cert \
5. --host $( \
6. az container list \
7. --resource-group $GROUP \
8. --query "[?name=='edgedb-container-group'].ipAddress.fqdn | [0]" \
9. --output tsv ) \
10. azure
You can now connect to your instance.
1. edgedb -I azure
