This directory contains Terraform modules and a deployment script for provisioning the sample's Azure resources. For details about the sample application, see Azure Web App with Azure Database for MySQL flexible server.
- LocalStack for Azure
- Terraform (1.5+)
- Docker
- Azure CLI + lstk CLI
- Python 3.12+
- MySQL client (
mysql) jq
brew install localstack/tap/lstk # or: npm install -g @localstack/lstkThe Terraform configuration provisions:
- Azure Resource Group.
- Azure Virtual Network with two subnets:
- app-subnet (delegated to
Microsoft.Web/serverFarmsfor the Web App's VNet integration) - pe-subnet (hosts the Private Endpoint to the flex server)
- app-subnet (delegated to
- Azure Private DNS Zone
privatelink.mysql.database.azure.com, linked to the VNet. - Azure Private Endpoint (group
mysqlServer). - Azure NAT Gateway.
- Network Security Groups: one per subnet.
- Azure Log Analytics Workspace.
- Azure Database for MySQL flexible server: public-access mode, Burstable
Standard_B1ms, version 8.0.21, 32 GiB, HA disabled. A permissive firewall rule (AllowAllIPs,0.0.0.0–255.255.255.255) lets the deploy machine reach the server for the post-apply mysql bootstrap. - MySQL database
plannerdb. - Azure App Service Plan.
- Azure Web App with regional VNet integration.
MYSQL_HOST/MYSQL_PORT/MYSQL_DATABASEare written by Terraform;MYSQL_USERandMYSQL_PASSWORDare written bydeploy.shafter the mysql client creates the application user.
deploy.sh performs:
terraform init -upgradeterraform plan -out=tfplan(passingmysql_admin_password)terraform apply -auto-approve tfplan- Reads outputs (
resource_group_name,web_app_name,mysql_server_name,mysql_fqdn,mysql_database_name). - Connects to the server as the admin via the public endpoint + firewall rule and creates the
testuseruser, grants privileges, creates theactivitiestable, and seeds the rows. - Sets
MYSQL_USER=testuser+MYSQL_PASSWORD=<app-password>on the Web App viaaz webapp config appsettings set. - Zips the source under
../srcand deploys viaaz webapp deploy.
Override any of the variables in variables.tf by editing terraform.tfvars or passing -var to terraform plan. Notable MySQL ones:
| Variable | Default | Description |
|---|---|---|
mysql_admin_login |
myadmin |
Server administrator login |
mysql_admin_password |
P@ssw0rd1234! |
Server administrator password (sensitive) |
mysql_version |
8.0.21 |
MySQL major version |
mysql_sku_name |
B_Standard_B1ms |
Compute SKU |
mysql_storage_size_gb |
32 |
Storage size in GB |
mysql_backup_retention_days |
7 |
Backup retention |
mysql_database_name |
plannerdb |
Application database |
For non-dev deployments, set mysql_admin_password via env var: MYSQL_ADMIN_PASSWORD=... bash deploy.sh.