Deploying a Python Flask Webapp to Azure App Service using Azure Pipelines

Kaan Turgut
5 min readJan 28, 2023

--

Prerequisites :

  • An Azure account with an active subscription. Create an account for free.
  • An Azure DevOps organization. Create an account for free.
  • An ability to run pipelines on Microsoft-hosted agents. You can either purchase a parallel job or you can request a free tier.
  • A working Azure App Service app with code hosted on GitHub or Azure Repos.

1- Create a Azure App Service ( Linux Web App ) >>> I chose creating by TERRASPACE

2- Create a Python app in Azure App Service using the provided documentation and code. >>> Documentation

3- Create your pipeline from Azure DevOps

  • Sign in to your Azure DevOps organization and navigate to your project.
  • Go to Pipelines, and then select New Pipeline.

4- In Azure DevOps, select GitHub as the location of your source code and select your repository.

  • - You might be redirected to GitHub to sign in. If so, enter your GitHub credentials.
  • When the list of repositories appears, select your repository.

5- In the Configure tab, select Python to Linux Web App on Azure.

  • Then the web app needs to be choosen.

6- Review the YAML and select Save and run.

7- Monitor the Build and Deployment jobs.

  • Build Job is done
  • Deployment Job is done
  • View the details, jobs, and environment in Azure DevOps.
  • We can see our JOBS here
  • We can see our environment here

8- Verify the deployment in the Azure portal.

PART 2 : Releases in Azure Pipeline

1- Go to Releases under the Pipeline tab and create a new Release pipeline.

2- The easiest way to create a release pipeline is to use a template. If you are deploying a Node.js app, select the Deploy Node.js App to Azure App Service template. Otherwise, select the Azure App Service Deployment template. Then choose Apply.

3- If you created your new release pipeline from a build summary, check that the build pipeline and artifact is shown in the Artifacts section on the Pipeline tab. If you created a new release pipeline from the Releases tab, choose the + Add link and select your build artifact.

4- Enable the continuous deployment trigger and add a filter to include the main branch.

5- Configure task property variables, such as Azure Subscription and App Service Name, in the Tasks tab.

Create a release to deploy your app

  • Choose + Release and select Create a release.
  • In the Create a new release panel, check that the artifact version you want to use is selected and choose Create.
  • Monitor the pipeline view and view the logs and agent output.
  • View the release summary.

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

To test the release pipeline, make some changes to the index.html file in the Python app and then commit and push the changes to the repository. This will initiate the pipeline and deploy the updated code to the Azure App Service automatically . You can monitor the progress of the release in the pipeline view and check the logs and agent output to ensure that the pipeline is working properly.

  • Finally, you can verify the changes by accessing the web app in the Azure portal to ensure that the updated code has been successfully deployed.

--

--

No responses yet