name | description | languages | products | page_type | urlFragment | ||||
---|---|---|---|---|---|---|---|---|---|
Flask App on Azure App Service |
Deploy a Flask app on App Service using Azure Developer CLI. |
|
|
sample |
simple-flask-server-appservice |
This repository includes a very simple Python Flask web site, made for demonstration purposes only.
This project has Dev Container support, so it will be be setup automatically if you open it in Github Codespaces or in local VS Code with the Dev Containers extension.
If you're not using one of those options for opening the project, then you'll need to:
-
Create a Python virtual environment and activate it.
-
Install requirements:
python3 -m pip install -r requirements.txt
-
Run the server:
python3 -m flask run --port 50505 --debug
-
Click 'http://127.0.0.1:50505' in the terminal, which should open the website in a new tab.
-
Try the index page, try '/hello?name=yourname', and try other paths.
This repo is set up for deployment on Azure App Service using the configuration files in the infra
folder.
Steps for deployment:
-
Sign up for a free Azure account
-
Install the Azure Dev CLI. (If you opened this repository in a devcontainer, that part will be done for you.)
-
Login to your Azure account:
azd auth login
-
Provision and deploy all the resources:
azd up
It will prompt you to login and to provide a name (like "flask-app") and location (like "eastus"). Then it will provision the resources in your account and deploy the latest code.
-
When
azd
has finished deploying, you'll see an endpoint URI in the command output. Visit that URI, and you should see the front page of the app! 🎉 If you see an error, open the Azure Portal from the URL in the command output, navigate to the App Service, select Logstream, and check the logs for any errors. -
When you've made any changes to the app code, you can just run:
azd deploy
By default, this project is set up to deploy to the free plan of Azure App Service. The free plan is intended for trials, experimentation, and learning the service. There is no SLA for free plan and it is metered on a per app basis. Use of free plan for production workloads is not supported.
If you would like to deploy to a paid plan, you can set the AZURE_APP_SERVICE_SKU
environment variable to B1
or other SKU before running azd up
:
azd env set AZURE_APP_SERVICE_SKU B1
Learn more about App Service pricing.
azd down
.