You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: samples/web-app-mysql-flexible-server/python/README.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Azure Web App with Azure Database for MySQL flexible server
2
2
3
-
This sample demonstrates a Python Flask single-page web application called *Vacation Planner* hosted on an [Azure Web App](https://learn.microsoft.com/en-us/azure/app-service/overview). The app runs on an Azure App Service Plan and stores activity data in the `activities` table of the `PlannerDB` database on an [Azure Database for MySQL flexible server](https://learn.microsoft.com/en-us/azure/mysql/flexible-server/overview). The server is reached through a [Private Endpoint](https://learn.microsoft.com/azure/private-link/private-endpoint-overview) (group `mysqlServer`) with the `privatelink.mysql.database.azure.com` Private DNS Zone, while a permissive server-level firewall rule lets the deploy machine run the post-create mysql bootstrap that creates the application user and seeds the schema.
3
+
This sample demonstrates a Python Flask single-page web application called *Vacation Planner* hosted on an [Azure Web App](https://learn.microsoft.com/en-us/azure/app-service/overview). The app runs on an Azure App Service Plan and stores activity data in the `activities` table of the `plannerdb` database on an [Azure Database for MySQL flexible server](https://learn.microsoft.com/en-us/azure/mysql/flexible-server/overview). The server is reached through a [Private Endpoint](https://learn.microsoft.com/azure/private-link/private-endpoint-overview) (group `mysqlServer`) with the `privatelink.mysql.database.azure.com` Private DNS Zone, while a permissive server-level firewall rule lets the deploy machine run the post-create mysql bootstrap that creates the application user and seeds the schema.
4
4
5
5
## Architecture
6
6
@@ -14,7 +14,7 @@ flowchart LR
14
14
nat["NAT Gateway"]
15
15
dns["Private DNS Zone<br/>privatelink.mysql.database.azure.com"]
@@ -49,13 +49,13 @@ The web app enables users to plan and manage vacation activities; all data is pe
49
49
5.[Azure NAT Gateway](https://learn.microsoft.com/azure/nat-gateway/nat-overview): Deterministic outbound connectivity for both subnets.
50
50
6.[Azure Network Security Group](https://learn.microsoft.com/en-us/azure/virtual-network/network-security-groups-overview): One NSG per subnet.
51
51
7.[Azure Log Analytics Workspace](https://learn.microsoft.com/azure/azure-monitor/logs/log-analytics-overview): Centralizes diagnostic logs and metrics.
52
-
8.[Azure Database for MySQL flexible server](https://learn.microsoft.com/en-us/azure/mysql/flexible-server/overview): Public-access server hosting the `PlannerDB` database. Burstable `Standard_B1ms`, version 8.0.21, 32 GiB storage, 7-day backup retention, HA disabled. A permissive firewall rule (`0.0.0.0–255.255.255.255`) is created so the deploy machine can run the post-create mysql bootstrap; the Web App itself reaches the server through the Private Endpoint.
53
-
9.[MySQL database](https://learn.microsoft.com/en-us/azure/mysql/flexible-server/how-to-create-manage-databases)`PlannerDB`: Created at provisioning time; the post-deploy mysql step creates the `activities` table and seeds the demo rows.
52
+
8.[Azure Database for MySQL flexible server](https://learn.microsoft.com/en-us/azure/mysql/flexible-server/overview): Public-access server hosting the `plannerdb` database. Burstable `Standard_B1ms`, version 8.0.21, 32 GiB storage, 7-day backup retention, HA disabled. A permissive firewall rule (`0.0.0.0–255.255.255.255`) is created so the deploy machine can run the post-create mysql bootstrap; the Web App itself reaches the server through the Private Endpoint.
53
+
9.[MySQL database](https://learn.microsoft.com/en-us/azure/mysql/flexible-server/how-to-create-manage-databases)`plannerdb`: Created at provisioning time; the post-deploy mysql step creates the `activities` table and seeds the demo rows.
54
54
10.[Azure App Service Plan](https://learn.microsoft.com/en-us/azure/app-service/overview-hosting-plans): The underlying compute tier that hosts the web application.
55
55
11.[Azure Web App](https://learn.microsoft.com/en-us/azure/app-service/overview): Runs the Python Flask *Vacation Planner* app with regional VNet integration into *app-subnet*. The Web App connects to MySQL using a dedicated application user (`testuser`) — the server-admin login is never used at runtime.
56
56
12.[App Service Source Control](https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/create-or-update-source-control?view=rest-appservice-2024-11-01): *(Optional)* Configures continuous deployment from a public GitHub repository.
57
57
58
-
The deploy scripts follow the same pattern as the sibling [`web-app-postgresql-flexible-server`](../../web-app-postgresql-flexible-server/python/) sample: after provisioning, they (i) connect as the server admin via the public endpoint + firewall rule, (ii) create the application user `testuser` with its own password, (iii) grant privileges on `PlannerDB`, (iv) create the `activities` table, (v) seed sample rows, and (vi) write `MYSQL_USER=testuser` + `MYSQL_PASSWORD` onto the Web App's app settings. The server-admin login is never written into the Web App's runtime configuration.
58
+
The deploy scripts follow the same pattern as the sibling [`web-app-postgresql-flexible-server`](../../web-app-postgresql-flexible-server/python/) sample: after provisioning, they (i) connect as the server admin via the public endpoint + firewall rule, (ii) create the application user `testuser` with its own password, (iii) grant privileges on `plannerdb`, (iv) create the `activities` table, (v) seed sample rows, and (vi) write `MYSQL_USER=testuser` + `MYSQL_PASSWORD` onto the Web App's app settings. The server-admin login is never written into the Web App's runtime configuration.
59
59
60
60
## Prerequisites
61
61
@@ -117,14 +117,14 @@ You can use [MySQL Workbench](https://www.mysql.com/products/workbench/) to expl
7.[Azure Database for MySQL flexible server](https://learn.microsoft.com/en-us/azure/mysql/flexible-server/overview): public-access mode, Burstable `Standard_B1ms`, version 8.0.21, 32 GiB, HA disabled. A permissive firewall rule (`0.0.0.0–255.255.255.255`) lets the deploy machine reach the server for the post-create mysql bootstrap.
9.[Azure App Service Plan](https://learn.microsoft.com/en-us/azure/app-service/overview-hosting-plans).
34
34
10.[Azure Web App](https://learn.microsoft.com/en-us/azure/app-service/overview) with regional VNet integration into *app-subnet*. The Bicep template sets `MYSQL_HOST`, `MYSQL_PORT`, and `MYSQL_DATABASE` on the Web App but **does not** set `MYSQL_USER` or `MYSQL_PASSWORD` — those are written by `deploy.sh` after the mysql client creates the application user.
35
35
@@ -44,7 +44,7 @@ param prefix = 'local'
44
44
param suffix = 'test'
45
45
param runtimeName = 'python'
46
46
param runtimeVersion = '3.13'
47
-
param databaseName = 'PlannerDB'
47
+
param databaseName = 'plannerdb'
48
48
param username = 'paolo'
49
49
50
50
param mysqlAdminLogin = 'myadmin'
@@ -82,7 +82,7 @@ The script will:
82
82
## Verification
83
83
84
84
```bash
85
-
MYSQL_PWD='TestP@ssw0rd123' mysql -h <fqdn> -P <port> -u testuser PlannerDB \
85
+
MYSQL_PWD='TestP@ssw0rd123' mysql -h <fqdn> -P <port> -u testuser plannerdb \
86
86
-e "SELECT id, username, activity, created_at FROM activities;"
Copy file name to clipboardExpand all lines: samples/web-app-mysql-flexible-server/python/scripts/README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,10 +27,10 @@ pip install azlocal
27
27
-*app-subnet*: delegated to `Microsoft.Web/serverFarms` (with NAT gateway).
28
28
-*pe-subnet*: hosts the Private Endpoint (no delegation; `disable-private-endpoint-network-policies=true`).
29
29
6.[Azure Database for MySQL flexible server](https://learn.microsoft.com/en-us/azure/mysql/flexible-server/overview): public-access mode, `Burstable / Standard_B1ms`, version 8.0.21, 32 GiB, HA disabled. With a permissive `AllowAllIPs` firewall rule.
30
-
7. The `PlannerDB`[database](https://learn.microsoft.com/en-us/azure/mysql/flexible-server/how-to-create-manage-databases).
30
+
7. The `plannerdb`[database](https://learn.microsoft.com/en-us/azure/mysql/flexible-server/how-to-create-manage-databases).
31
31
8.[Azure Private DNS Zone](https://learn.microsoft.com/azure/dns/private-dns-privatednszone)`privatelink.mysql.database.azure.com`, linked to the VNet.
32
32
9.[Azure Private Endpoint](https://learn.microsoft.com/azure/private-link/private-endpoint-overview) targeting the MySQL server with group `mysqlServer`, plus the DNS-zone group that auto-registers the A record.
33
-
10. A separate application user (`testuser`) created via the `mysql` client, with privileges on `PlannerDB`.
33
+
10. A separate application user (`testuser`) created via the `mysql` client, with privileges on `plannerdb`.
34
34
11. The `activities` table and the seeded rows.
35
35
12.[Azure App Service Plan](https://learn.microsoft.com/en-us/azure/app-service/overview-hosting-plans).
36
36
13.[Azure Web App](https://learn.microsoft.com/en-us/azure/app-service/overview) with regional VNet integration into *app-subnet*, configured with `MYSQL_HOST`, `MYSQL_PORT`, `MYSQL_USER=testuser`, `MYSQL_PASSWORD`, `MYSQL_DATABASE`, `LOGIN_NAME`, `WEBSITES_PORT`.
8.[Azure Database for MySQL flexible server](https://learn.microsoft.com/en-us/azure/mysql/flexible-server/overview): 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.
10.[Azure App Service Plan](https://learn.microsoft.com/en-us/azure/app-service/overview-hosting-plans).
35
35
11.[Azure Web App](https://learn.microsoft.com/en-us/azure/app-service/overview) with regional VNet integration. `MYSQL_HOST` / `MYSQL_PORT` / `MYSQL_DATABASE` are written by Terraform; `MYSQL_USER` and `MYSQL_PASSWORD` are written by `deploy.sh` after the mysql client creates the application user.
36
36
@@ -58,6 +58,6 @@ Override any of the variables in [`variables.tf`](variables.tf) by editing [`ter
0 commit comments