title | description | services | documentationcenter | author | manager | editor | ms.assetid | ms.service | ms.workload | ms.tgt_pltfrm | ms.devlang | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Deploy your first Python web app to Azure in five minutes | Microsoft Docs |
Learn how easy it is to run web apps in App Service by deploying a sample app. Start doing real development quickly and see results immediately. |
app-service\web |
cephalin |
wpickett |
928ee2e5-6143-4c0c-8546-366f5a3d80ce |
app-service-web |
web |
na |
na |
hero-article |
10/13/2016 |
cephalin |
This tutorial helps you deploy your first Python web app to Azure App Service. You can use App Service to create web apps, mobile app back ends, and API apps.
You will:
- Create a web app in Azure App Service.
- Deploy sample Python code.
- See your code running live in production.
- Update your web app the same way you would push Git commits.
- Git.
- Azure CLI.
- A Microsoft Azure account. If you don't have an account, you can sign up for a free trial or activate your Visual Studio subscriber benefits.
Note
You can Try App Service without an Azure account. Create a starter app and play with it for up to an hour--no credit card required, no commitments.
-
Open a new Windows command prompt, PowerShell window, Linux shell, or OS X terminal. Run
git --version
andazure --version
to verify that Git and Azure CLI are installed on your machine.If you haven't installed the tools, see Prerequisites for download links.
-
Log in to Azure like this:
azure login
Follow the help message to continue the login process.
-
Change Azure CLI into ASM mode, then set the deployment user for App Service. You will deploy code using the credentials later.
azure config mode asm azure site deployment user set --username <username> --pass <password>
-
Change to a working directory (
CD
) and clone the sample app like this:git clone https://github.com/Azure-Samples/app-service-web-python-get-started.git
-
Change to the repository of your sample app. For example:
cd app-service-web-python-get-started
-
Create the App Service app resource in Azure with a unique app name and the deployment user you configured earlier. When you're prompted, specify the number of the desired region.
azure site create <app_name> --git --gitusername <username>
Your app is created in Azure now. Also, your current directory is Git-initialized and connected to the new App Service app as a Git remote. You can browse to the app URL (http://<app_name>.azurewebsites.net) to see the beautiful default HTML page, but let's actually get your code there now.
-
Deploy your sample code to your Azure app like you would push any code with Git. When prompted, use the password you configured earlier.
git push azure master
git push
not only puts code in Azure, but also triggers deployment tasks in the deployment engine. If you have any requirements.txt (Python) files in your project (repository) root, the deployment script restores the required packages for you.
Congratulations, you have deployed your app to Azure App Service.
To see your app running live in Azure, run this command from any directory in your repository:
azure site browse
You can now use Git to push from your project (repository) root anytime to make an update to the live site. You do it the same way as when you deployed your code the first time. For example, every time you want to push a new change that you've tested locally, just run the following commands from your project (repository) root:
git add .
git commit -m "<your_message>"
git push azure master
Create, configure, and deploy a Django web app to Azure in Visual Studio. By following this tutorial, you will learn the basic skills you need to run a Python web app in Azure, including:
- Create and deploy a Python app using a template.
- Set Python version.
- Create virtual environments.
- Connect to a database.
Or, do more with your first web app. For example:
- Try out other ways to deploy your code to Azure. For example, to deploy from one of your GitHub repositories, simply select GitHub instead of Local Git Repository in Deployment options.
- Take your Azure app to the next level. Authenticate your users. Scale it based on demand. Set up some performance alerts. All with a few clicks. See Add functionality to your first web app.