Santosh Venkatesan
3 min readMar 24, 2024

How to deploy the application to an environment based on the specific branch where the build was performed — Azure DevOps

Deploying to an environment based on the branch where the build was performed in Azure DevOps involves a few steps. Azure DevOps pipeline provides a powerful platform for automating CI/CD workflows, including the ability to trigger deployments based on specific conditions like branch names

Pre-requisites

  1. Azure Portal with required access
  2. Azure DevOps portal with required access
  3. Basic knowledge in Azure DevOps and Azure Portal

Step1: Environment readiness

Provision 3 App services as below under resource group called Azuredevops-rg

santhuqa — QA Environment

santhuuat — UAT Environment

santhuprod — Production environment

App service plan is MyAppServicePlan

Repeat the same steps for UAT and Production app services

Finally, all three app services has been created under the same Azure Service plan and resource group

Step2:

Create an Azure DevOps Private Project and Service Connection under project settings (Select ARM and Service Principal automatic options)

Select Subscriptions and resource group where your app services belong to

Step3:

Push your code to the local repo using GIT commands then move to Azure Repos

you can download the code from the below repo

https://dev.azure.com/santoshvenkatesan/AzureDevOpsBranchingDemo

Step4:

Create QA and UAT branches from the master branch

Step5: Creation of Build pipeline using Classic editor

Click on Pipeline → New Pipeline → click Classic editor and select ASP.NET Core template

Provide required details and save the Build pipeline ( CI )

Trigger the build pipeline

Step6: Creation of Release Pipeline

Create 3 stages for QA, UAT and Production.

select the service connection that you have created in the previous step and select the respective App service name

Step6:

Now Build and Release pipelines are ready. It is time for testing

Step7:

Make some changes and commit the code on the master branch

Notice that your build and release pipeline automatically triggered and deployed the application ONLY on the Production environment

QA and UAT environments are skipped due to conditions not met

Watch the demo on YouTube — https://www.youtube.com/watch?v=JsoKH4JhZJY

In the next video will see the same example with the YAML pipeline