A one-command Azure deployment of the LearningSteps API and a PostgreSQL database.
This deployment is intentionally minimal and unsecured. The VM is publicly reachable, the database accepts connections from any IP, credentials are stored in plaintext, and there is no traffic inspection or monitoring. It is a starting point — not a production setup.
- Ubuntu VM (Standard_D2s_v3) running the FastAPI application on port 8000
- Azure PostgreSQL Flexible Server (B1ms) as the database
- A virtual network with one subnet and a basic network security group
Install the following before running the script:
| Tool | Install |
|---|---|
| Python 3.8+ | python.org — on Windows use python, on macOS/Linux use python3 |
| Terraform ≥ 1.5 | developer.hashicorp.com/terraform/install |
| Azure CLI | learn.microsoft.com/en-us/cli/azure/install-azure-cli |
| Azure subscription | Your account needs Contributor or Owner role on the subscription |
python3 deploy.pyOn Windows:
python deploy.py
The script will:
- Log you in to Azure if needed (opens a browser)
- Generate an SSH key pair in the project folder
- Ask for a resource prefix and Azure region (IMPORTANT - Make sure your prefix is unique and includes your name, otherwise the deployment will fail due to naming conflicts)
- Ask for a PostgreSQL admin password
- Run
terraform apply— takes about 7–8 minutes - Run a smoke test against the deployed API
To skip the interactive prompts:
python3 deploy.py --password YourPassword1 --prefix learningstepsbob --location westeuropeOnce deployed, the script prints the API URL and SSH command.
When not in use, deallocate the VM to avoid compute charges:
az vm deallocate --resource-group rg-<prefix> --name vm-<prefix>Start it again:
az vm start --resource-group rg-<prefix> --name vm-<prefix>Stop the database:
az postgres flexible-server stop --resource-group rg-<prefix> --name psql-<prefix>-<suffix>Start it again:
az postgres flexible-server start --resource-group rg-<prefix> --name psql-<prefix>-<suffix>Note: Azure automatically restarts a stopped PostgreSQL Flexible Server after 7 days.
To destroy everything permanently:
terraform destroyThe SSH key is generated in the project folder during deployment:
ssh azureuser@<vm-ip> -i .learningsteps_key