Last updated : Aug 26, 2019.


Python is a server-side scripting language and a powerful tool for making dynamic and interactive web pages.

This lab shows how to deploy a Python application to Azure App Service from Visual Studio Team Services. We will use with Django framework for deployment.

Prerequisites for the lab

  1. Microsoft Azure Account: You will need a valid and active Azure account for the Azure labs. If you do not have one, you can sign up for a free trial

    • If you are an active Visual Studio Subscriber, you are entitled for a $50-$150 credit per month. You can refer to this link to find out more information about this including how to activate and start using your monthly Azure credit.

    • If you are not a Visual Studio Subscriber, you can sign up for the FREE Visual Studio Dev Essentials program to create a Azure free account (includes 1 year of free services, $200 for 1st month).

  2. You will need a Visual Studio Team Services Account. If you do not have one, you can sign up for free here

  3. You will need a Personal Access Token to set up your project using the VSTS Demo Generator. Please see this article for instructions to create your token.

Setting Up the VSTS Project

  1. Use the VSTS Demo Generator to provision a Python project on your VSTS account.

    VSTS Demo Generator helps you create team projects on your VSTS account with sample content that include source code, work items,iterations, service endpoints, build and release definitions based on the template you choose during the configuration.


  2. Once the project is provisioned, click the URL to navigate to the project.


Exercise 1: Endpoint Creation

Since the connections are not established during project provisioning, we will manually create the endpoints.

In VSTS, navigate to Services by clicking the gear icon, and click + New Service Endpoint. Select Azure Resource Manager. Specify connection name, select your subscription from the drop down and click OK. We use this endpoint to connect VSTS with Azure.


You will be prompted to authorize this connection with Azure credentials.

Exercise 2: Configure Release

We will provision the resources on Azure using ARM template in the release definition.

  1. Go to Releases under Build and Release tab, Select release definition Python and click Edit


  2. Go to Tasks and select Dev environment.


  3. Under Azure Resource Group Deployment task, update Azure subscription and Location.


  4. Under Install Python Extension task, update Azure subscription.


  5. Under Azure App Service Deploy task, update Azure subscription and click Save.


    Tasks Usage
    Azure Resource Group Deployment This task will create a resource group with the name Python and provision an App service and App Service Plan
    Install Python Extension Installs the specific version of Python into Azure App Service
    Azure App Service Deploy The task is used to update Azure App Service to deploy Web Apps to azure.

Exercise 3: Trigger CI-CD with code change

Python is an interpreted language, and hence compilation is not required. We will archive the files in the build and use the package in the release for deployment. Update the code to trigger CI-CD using Hosted build agent.

  1. Go to Code tab and navigate to the below path to edit the file.


  2. Go to line number 32, modify Continuous Delivery to Continuous Delivery for Python and commit the code.


  3. Go to Builds tab under Build and Release tab to see the build in progress.



    Let’s explore the build definition while the build is in-progress. The tasks used are listed as shown.

    Tasks Usage
    Archive files creates zip file for deployment
    Copy Files copies ARM template which is used to provision resources on azure
    Publish Build Artifacts publishes the build artifacts
  4. The build generates artifact which is used for deployment to Azure.


  5. Once the build is complete, it triggers the CD pipeline. You can notice the linked release is in progress by navigating to Releases under Build and Release. The release will provision the Azure Web app and deploy the zip file generated by the associated build.



  6. Login to Azure Portal and go to the Resource Group with the name Python. You will see the resources App Service and App Service Plan.


  7. Select the App Service and from the Overview tab, click Browse to see the application deployed.



This lab shows how to create a continuous integration(CI) and continuous deployment (CD) pipeline for Python code with Visual Studio Team Services (VSTS) on Azure.