Azure app service is a fully managed compute platform that is optimized for hosting websites and web applications.
- Azure Subscription
- Python 3.7
- Git
- Azure Command LIne Interface
Step 1
Download the sample code
In a terminal window, to run the following command to clone the sample application to your local computer
- git clone https://github.com/Azure-Samples/python-docs-hello-world
Then, go the folder
- cd python-docs-hello-world
Step 2
Run the sample code
In a terminal window, run the following code
- py -3 -m venv env
- env\scripts\activate
- pip install -r requirements.txt
- SET FLASK_APP=application.py
- flask run
Step 3
Open a web browser, and go to the sample app at http://localhost:5000/
The webpage will display the following page
Step 4
Sign in to Azure
Using Command LIne Interface
The Azure CLI provides you with many convenient commands that you use from a local terminal to provision and manage Azure resources from the command line. You can use commands to complete the same tasks that you would through the Azure portal in a browser.
Run the code
Deploy the Sample Code
In the CLI terminal
- az webapp up --sku F1 -n demo-app -l centralus
You get following output:
- The behavior of this command has been altered by the following extension: webapp
- Creating Resource group 'appsvc_rg_Linux_centralus' ...
- Resource group creation complete
- Creating App service plan 'appsvc_asp_Linux_centralus' ...
- App service plan creation complete
- Creating app 'demo-app' ....
- Webapp creation complete
- Creating zip with contents of dir /home/username/quickstart/python-docs-hello-world ...
- Preparing to deploy contents to app.
- All done.
- {
- "app_url": "https:/demo-app.azurewebsites.net",
- "location": "Central US",
- "name": "demo-app",
- "os": "Linux",
- "resourcegroup": "appsvc_rg_Linux_centralus ",
- "serverfarm": "appsvc_asp_Linux_centralus",
- "sku": "BASIC",
- "src_path": "/home/username/quickstart/python-docs-hello-world ",
- "version_detected": "-",
- "version_to_create": "python|3.7"
- }
Step 6
Browse the app
Browse the URL http://demo-app.azurewebsites.net.
You get the following output.
The web application is successfully deployed.
Step 7
Manage the Azure App
In your Azure portal ->Search
Then, Click your app name. You'll see your azure app processing details.
Conclusion
In this article, we learned how to deploy a Python app in Azure app service on Linux OS. I hope you understood how deploy an Azure app on Linux OS. Thank you for your reading. Any doubts in this article, please ask me.