Configure the blue-green deployment strategy for Azure Linux virtual machines
Applies to: ✔️ Linux VMs
Azure Pipelines provides a fully featured set of CI/CD automation tools for deployments to virtual machines. This article will show you how to set up a classic release pipeline that uses the blue-green strategy to deploy to Linux virtual machines. Azure also supports other strategies like rolling and canary deployments.
Blue-green deployments
A blue-green deployment is a deployment strategy where you create two separate and identical environments but only one is live at any time. This strategy is used to increase availability and reduce downtime by switching between the blue/green environments. The blue environment is usually set to run the current version of the application while the green environment is set to host the updated version. When all updates are completed, traffic is directed to the green environment and blue environment is set to idle.
Using the Continuous-delivery feature, you can use the blue-green deployment strategy to deploy to your virtual machines from Azure portal.
Sign in to Azure portal and navigate to a virtual machine.
ISelect Continuous delivery, and then select Configure.
In the configuration panel, select Use existing and select your organization/project or select Create and create new ones.
Select your Deployment group name from the dropdown menu or create a new one.
Select your Build pipeline from the dropdown menu.
Select the Deployment strategy dropdown menu, and then select Blue-Green.
Add a "blue" or "green" tag to VMs that are used for blue-green deployments. If a VM is for a standby role, tag it as "green". Otherwise, tag it as "blue".
Select OK to configure the classic release pipeline to deploy to your virtual machine.
Navigate to your release pipeline and then select Edit to view the pipeline configuration. In this example, the dev stage is composed of three jobs:
Deploy Green: the app is deployed to a standby VM tagged "green".
Wait for manual resumption: the pipeline pauses and waits for manual intervention.
Swap Blue-Green: this job swaps the "blue" and "green" tags in the VMs. This ensures that VMs with older application versions are now tagged as "green". During the next pipeline run, applications will be deployed to these VMs.