Quickstart: Create A Python App Using Azure App Service On Linux
Quickstart: Create A Python App Using Azure App Service On Linux
Choose a framework
Flask Django
In this quickstart, you deploy a Python web app to App Service on Linux, Azure's highly
scalable, self-patching web hosting service. You use the local Azure command-line
interface (CLI) on a Mac, Linux, or Windows computer to deploy a sample with either the
Flask or Django frameworks. The web app you configure uses a basic App Service tier
that incurs a small cost in your Azure subscription.
Open a terminal window and check your Python version is 3.6 or higher:
Bash
PowerShell
Cmd
BashCopy
python3 --version
Azure CLICopy
az --version
Then sign in to Azure through the CLI:
Azure CLICopy
az login
This command opens a browser to gather your credentials. When the command finishes,
it shows JSON output containing information about your subscriptions.
Once signed in, you can run Azure commands with the Azure CLI to work with resources
in your subscription.
Clone the sample repository using the following command and navigate into the sample
folder. (Install git if you don't have git already.)
terminalCopy
git clone https://github.com/Azure-Samples/python-docs-hello-world
The sample contains framework-specific code that Azure App Service recognizes when
starting the app. For more information, see Container startup process.
terminalCopy
cd python-docs-hello-world
o Bash
o PowerShell
o Cmd
BashCopy
# Linux systems only
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
If you're on a Windows system and see the error "'source' is not recognized
as an internal or external command," make sure you're either running in the
Git Bash shell, or use the commands shown in the Cmd tab above.
terminalCopy
flask run
By default, the server assumes that the app's entry module is in app.py, as
used in the sample.
If you encounter the error, "Could not locate a Flask application. You did not
provide the 'FLASK_APP' environment variable, and a 'wsgi.py' or 'app.py'
module was not found in the current directory.", make sure you're in
the python-docs-hello-world folder that contains the sample.