Deploying EdgeDB to Azure
In this guide we show how to deploy EdgeDB using Azure’s Postgres Flexible Server as the backend.
Prerequisites
- Valid Azure Subscription with billing enabled or credits (free trial).
- Azure CLI (install).
Provision an EdgeDB instance
Login to your Microsoft Azure account.
1. $
1. az login
Create a new resource group.
1. $
1. GROUP=my-group-name
1. $
1. az group create --name $GROUP --location westus
Provision a PostgreSQL server.
If you already have a database provisioned you can skip this step.
For convenience, assign a value to the PG_SERVER_NAME environment variable; we’ll use this variable in multiple later commands.
1. $
1. PG_SERVER_NAME=postgres-for-edgedb
Use the read command to securely assign a value to the PASSWORD environment variable.
1. $
1. echo -n "> " && read -s PASSWORD
Then create a Postgres Flexible server.
1. $
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 13 \
9. --yes
If you get an error saying "Specified server name is already used."" change the value of PG_SERVER_NAME and rerun the command.
Allow other Azure services access to the Postgres instance.
1. $
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
EdgeDB requires postgres’ uuid-ossp extension which needs to be enabled.
1. $
1. az postgres flexible-server parameter set \
2. --resource-group $GROUP \
3. --server-name $PG_SERVER_NAME \
4. --name azure.extensions \
5. --value uuid-ossp
Start an EdgeDB container.
1. $
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. $
1. DSN="postgresql://edgedb:$PASSWORD@$PG_HOST/postgres?sslmode=require"
1. $
1. az container create \
2. --resource-group $GROUP \
3. --name edgedb-container-group \
4. --image edgedb/edgedb \
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. $
1. key="$( az container exec \
2. --resource-group $GROUP \
3. --name edgedb-container-group \
4. --exec-command "cat /tmp/edgedb/edbprivkey.pem" \
5. | tr -d "\r" )"
1. $
1. cert="$( az container exec \
2. --resource-group $GROUP \
3. --name edgedb-container-group \
4. --exec-command "cat /tmp/edgedb/edbtlscert.pem" \
5. | tr -d "\r" )"
1. $
1. az container delete \
2. --resource-group $GROUP \
3. --name edgedb-container-group \
4. --yes
1. $
1. az container create \
2. --resource-group $GROUP \
3. --name edgedb-container-group \
4. --image edgedb/edgedb \
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. $
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. $
1. edgedb -I azure
