Skip to main content

Step by step: Deploying a web app using Azure DevOps

DevOps is a very broad term that can apply to many things. In a sentence, it's a way to tie development and operations together through an automated workflow, allowing builds to quickly and seamlessly go from commit, to test, to production. But DevOps is also the name of a service that Microsoft offers, called Azure DevOps. This service is available both for on-premise using DevOps Server, and in the cloud with DevOps Service. Here, we'll look at deploying a very simple Python web app from GitHub to Azure, first to a test environment and then to production.

The first thing you need to do is make sure you have an Azure subscription and go to the Azure DevOps web page to get started. Once on your dashboard, create a new project, name it, and keep the default options:

Once the project is created, you'll see links to various features like boards, repos, tests and pipelines. Azure DevOps includes a lot of different services that can help you improve the workflow of your application. While most pipelines like GitLab and Travis-ci would typically be created in code, Azure allows you to create the entire thing through a web UI, which is good for when you're just starting up.

Click on the pipelines link on the left side of the dashboard, then select GitHub:

Here you'll have to log into your GitHub account (or create one if you don't have one already) and connect it to Azure DevOps. For our sample application, I already prepared a repo with the code at although you'll want to make sure you first clone it in your own GitHub account by clicking the Fork button in the upper right of that GitHub page so you can select it in Azure DevOps.

Once you select the repository in Azure DevOps, you'll be asked to install the Azure Pipelines app. Once you approve it, you'll be asked what kind of target you want to use. Here, we want to deploy to Azure as a Python web app, so pick that option:

You may have to confirm your Azure subscription, then you'll be brought to the last page with your YAML file. This file is basically a script that summarizes everything we've configured so far, and tells Azure what to do with your code, and how to deploy it. The file will be saved in your repo with the name azxure-pipelines.yml. You may want to go over it and check if there's things you'd like to change, such as the Python version, the requirements, the name of the app, etc. You can also see the pipeline is divided in two steps: Deploy and Build. This is so the build phase can happen and be tested first, to make sure everything is fine, before it gets deployed into production.

Once you save the file, you can make a commit and the pipeline should run automatically:

This page shows you the pipeline as it goes through, and if all went well, your app will be brought in, built, and then deployed directly in Azure. If not, then you can dig into the various steps of the pipeline to see what the error is. For example, in this case the web app doesn't actually exist in Azure since we haven't created it yet:

In order for the pipeline to work, the target must already exist. So if you go to the Azure portal, you can create a new web app with the app name and runtime that you gave during the pipeline creation:

This will give you a URL where you can see the default Azure web app running. Once the environment is up, you can go back to your pipeline, then run it again from the web page. This time, it should succeed, assuming the pipeline configuration matches the environment you created, and deploy the application to the Azure web server.

From here, you can work on adding extra testing phases, deploying more environments for development and staging, and so on. Don't forget to shut down your Azure environment once done so it doesn't cost you money.