Skip to content

Latest commit

 

History

History
118 lines (87 loc) · 5.65 KB

app-service-web-get-started-python.md

File metadata and controls

118 lines (87 loc) · 5.65 KB
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

Deploy your first Python web app to Azure in five minutes

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.

Prerequisites

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.

Deploy a Python web app

  1. Open a new Windows command prompt, PowerShell window, Linux shell, or OS X terminal. Run git --version and azure --version to verify that Git and Azure CLI are installed on your machine.

    Test installation of CLI tools for your first web app in Azure

    If you haven't installed the tools, see Prerequisites for download links.

  2. Log in to Azure like this:

     azure login
    

    Follow the help message to continue the login process.

    Log in to Azure to create your first web app

  3. 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>
    
  4. 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
    
  5. Change to the repository of your sample app. For example:

     cd app-service-web-python-get-started
    
  6. 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>
    

    Create the Azure resource for your first web app in Azure

    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.

  7. 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
    

    Push code to your first web app in Azure

    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.

See your app running live

To see your app running live in Azure, run this command from any directory in your repository:

azure site browse

Make updates to your app

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

Next steps

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: