Are you trying to deploy a new update to the production environment? However, are you afraid of the risks involved with downtime or buggy application?

This is when Blue-Green Deployment comes to the rescue by providing a smooth transition to the new update. To understand how it is done, let us go through the blog, where weundefinedll see what Blue-Green Deployment is, and how it can be done in the Azure cloud with a step-by-step guide.

What is Blue-Green Deployment?


Blue-Green Deployment is a technique of running two applications, that are identical, in the production environment to reduce the risk of application downtime. Here, Blue deployment is the current version of an application, and green is the next/new version to be launched.

Let us understand this by example. Suppose the current application version is 1.0 (Blue Deployment), and the future version/new version is 2.0 (Green Deployment). Right now, multiple users are using version 1.0, however, the new version is to be deployed in the production environment, and donundefinedt want to give any downtime to the users. So to start the process, we would redirect a few users to the Green Deployment. Once it is confirmed that the new version can perform and sustain the traffic without any bugs or lag, we can redirect all users to the Green Deployment in a controlled manner.

Before starting with the Azure Blue-Green deployment, look at the following resources required for the whole process.

  1. Virtual Machine: is an azure service that connects you with your machine.
  2. Azure Database for PostgreSQL Flexi server: is hosted in a Linux-based Virtual machine that aligns with the Postgres engine architecture.
  3. Resource Group: holds related resources in Azure.
  4. V-net: represent your network
  5. Traffic Manager: This allows you to distribute public-facing applications in different regions in azure.
  6. Load balancer: provides high availability by distributing incoming traffic among healthy VMs.

There are two sets for the deployment. The first set is Blue Deployment which is your current version, and the other set is your Green deployment which is your next version of your application. Using the two different sets simultaneously helps to revert the application to the old version (Blue Deployment) if the new version (Green Deployment) cannot handle network traffic. For both sets, we have connected to the same database.

Now, we would be creating the load balancers for Blue and Green Deployments. While deploying the load balancer, attach the IP Address in the frontend pool and add the Virtual Machine to the backend pool (This step applies for both Blue and Green Deployment).

The question here is how we would know if the new version (Green Deployment) is ready for handling network traffic as expected?

We would be creating a weighted Traffic manager and attaching both load balancers to the traffic manager. Add 90% traffic to the Blue Deployment (current version) and 10% to the Green Deployment (new version) and send some user traffic requests to the traffic manager. If the output is as per the defined parameters, we can add 100% traffic to the Green Deployment.

Configuration of Blue-Green Deployment in azure cloud

How to create a Resource Group.

  1. Log in to, go to the resource group and click on Create a Resource Group.


  1. Click on Create.


How to create Virtual Machine

Note: There are the same steps for deploying a Green deployment virtual machine.

  1. Go to the Virtual Machines and click on Create.


  1. Add details according to your requirement.


  1. Select Storage type and click on Next.


  1. Enter networking details and select public IP as none.


  1. Set management to fulfill your requirement and click on Next.


  1. Set advanced settings as it fulfills your requirement.


  1. Add tags (optional) and create your Virtual Machine


How to create Azure Database for PostgreSQL flexible servers

  1. Open Azure database for PostgreSQL flexible servers and click on Create


  1. Select a flexible server.


  1. Select desired Resource Group, Workload type, and select postgre version. Now enter your username and generate a password

Note: Select the same Resource Group as we are using for Virtual Machine


  1. For the networking section, select the Private access for connectivity method. Also, select the same network as we used for the Virtual Machine.

Note: We would need a new subnet as the Virtual Machineundefineds subnet wonundefinedt work for the Postgre flexible server.


  1. Click on Create, and you will get the following output after the successful deployment.


How to Create Load Balancer in Azure

Note: For Green deployment as well, follow the same steps.

  1. Open a service name Load Balancer in Azure and click on Create


  1. Enter a basic configuration and click on Next.


  1. Click on Add frontend IP configuration and add Public IP address. (Either add an existing IP address or create a new one)


  1. Select Add Backend Pools


  1. For adding Virtual Machine in your backend pool, select Virtual Machine and click on Add.

Note: Select the same V-net as did for the Virtual Machine.


  1. If there is a requirement of adding an Inbound or Outbound rule, then add the tags and click on Review and Create.


  1. After a successful deployment, you will get an output like the image below.


  1. For adding the Health Probe for a health checkup, select the load balancer at the left panel, then you will see Health Probe, select and click on Add.


  1. Add health prob for 80 port and click on Add.


How to create a Traffic manager in Azure

  1. Open a service named Traffic Manager in the Azure portal and click on Create.


  1. Select Weighted Routing Method and select the resource group same as every previous resource and click on Create.


  1. After successful deployment, you will get the output same as below.


  1. Now select the traffic manager we just created, and you will be able to see Endpoints in the left panel, select and click on Add.

(Follow the same steps for adding the undefinedGreen Deploymentundefined endpoint)


  1. Select the Resource Group type as a Public IP address, then select the Public IP and click on Add.

(Select the same public IP Address as we added for the Frontend IP Configuration for the Load Balancer)

Note: We have added 90% for the Blue Deployment and for the rest 10% for the Green Deployment.


(For the output you will see DNS name URL at the Traffic managerundefineds overview section)

Note: For adding a Public IP address in the Endpoints, we need to add a DNS name in the IP Addressundefineds configuration.

  1. Search Public IP Address
  2. Select existing IP Address
  3. On the left panel select Configuration
  4. Enter the DNS name label
  5. Click on Save


Congratulations! Youundefinedve successfully deployed the new update of your application without any downtime, and the new version is running smoothly. In case of a major bug, that is not allowing the users to use it properly, you can roll back the update, work on it, and deploy it back.

We, at Seaflux, are Cloud enthusiasts who are helping enterprises worldwide. Have a query or want to discuss AI or Machine Learning projects? Schedule a meeting with us here, weundefinedll be happy to talk to you.

Jay Mehta - Director of Engineering
Jay Mehta

Director of Engineering

Contact Us