Artists Booking Venues powered by Python (Flask) and MySQL Database. There is no user authentication or per-user data stored.
The project is designed for deployment on Azure App Service with a MySQL flexible server. See deployment instructions below.
-
Download the project starter code locally
git clone https://github.com/john0isaac/flask-webapp-mysql-db.git cd flask-webapp-mysql-db
-
Install, initialize and activate a virtualenv using:
pip install virtualenv python -m virtualenv venv source venv/bin/activate
Note - In Windows, the
venv
does not have abin
directory. Therefore, you'd use the analogous command shown below:source venv\Scripts\activate
-
Install the dependencies:
pip install -r requirements.txt
-
Run the development server:
export FLASK_APP=app.py export FLASK_ENV=development export FLASK_DEBUG=true flask run --reload
For Windows, use
setx
command shown below:setx FLASK_APP app.py setx FLASK_ENV development setx FLASK_DEBUG true flask run --reload
-
Verify on the Browser
Navigate to project homepage http://127.0.0.1:5000/ or http://localhost:5000
This application is configured to work without connecting a database for the pages that doesn't interact with it. If you want to enable database operations you'll need to connect to a database.
-
Run the following commands to connect to a database:
export DEPLOYMENT_LOCATION=local export DB_USER= export DB_PASSWORD= export DB_HOST= export DB_NAME=
-
For windows, add configuration using:
setx DEPLOYMENT_LOCATION local setx DB_USER user setx DB_PASSWORD password setx DB_HOST host setx DB_NAME dbname
-
Run the development server again.
This repository is set up for deployment on Azure App Service (w/MySQL flexible server) using the configuration files in the infra
folder.
To deploy your own instance, follow these steps:
-
Sign up for a free Azure account
-
Install the Azure Dev CLI.
-
Initialize a new
azd
environment:azd init -t john0isaac/flask-webapp-mysql-db
It will prompt you to provide a name (like "flask-app") that will later be used in the name of the deployed resources.
-
Provision and deploy all the resources:
azd up
It will prompt you to login, pick a subscription, and provide a location (like "eastus"). Then it will provision the resources in your account and deploy the latest code. If you get an error with deployment, changing the location (like to "centralus") can help, as there may be availability constraints for some of the resources.
-
When azd has finished deploying, you'll see an endpoint URI in the command output. Visit that URI to browse the app! 🎉
If you make any changes to the app code, you can just run this command to redeploy it:
azd deploy
It is important to secure the databases in web applications to prevent unwanted data access. This infrastructure uses the following mechanisms to secure the MySQL database:
- Azure Firewall: The database is accessible only from other Azure IPs, not from public IPs. (Note that includes other customers using Azure).
- Admin Username: Randomly generated and stored in Key Vault.
- Admin Password: Randomly generated and stored in Key Vault.
- MySQL Version: Latest available on Azure, version 8.0, which includes security improvements.
Pricing varies per region and usage, so it isn't possible to predict exact costs for your usage.
You can try the Azure pricing calculator for the resources:
- Azure App Service: Free Tier with shared CPU cores, 1 GB RAM. Pricing
- MySQL Flexible Server: Burstable Tier with 1 CPU core, 20GB storage. Pricing is hourly. Pricing
- Key Vault: Standard tier with 2 secrets. Vaults are offered in two service tiers—standard and premium. Pricing
azd down
.