Blue/Green Deployments Using Azure Front Door
Blue/Green deployment is a software release strategy that gradually introduces application updates to a small group of users. If the updates are successful, the number of users accessing the new deployment is gradually increased until all users are on the new version. If issues arise, traffic can be redirected to the old version, ensuring minimal disruption. This approach is safer than deploying updates to all users at once.
Azure Front Door is Microsoft's modern cloud Content Delivery Network (CDN) that offers fast, reliable, and secure access to your application's static and dynamic web content globally. This article explains how to use Azure Front Door's global load balancing capabilities to implement a blue/green deployment model for your backends.
Prerequisites
- An Azure subscription. If you don't have an Azure subscription, create a free account before you begin.
Create an Azure Front Door profile
Sign in to the Azure portal.
Select Create a resource from the home page, search for Front Door and CDN profiles, and select Create.
Select Custom create on the Compare offerings page, and then select Continue to create a Front Door.
On the Basics tab, enter or select the following information:
Settings Values Subscription Select your subscription. Resource group Select Create new and enter myAFDResourceGroup
.Resource group location Select East US. Name Enter a unique name for your Front Door profile. Tier Select Standard. Select the Endpoints tab, and then select Add endpoint. Enter a globally unique name for your endpoint, and then select Add. You can create more endpoints after the deployment.
Select + Add a route to configure routing to your Web App origin.
Provide a name for the route and configure the route settings based on the needs of your application. For more information, see Create a Front Door for your application.
To create a new origin group, select Add a new origin group and enter
myOriginGroup
as the name.Select + Add to add an origin to the origin group. Enter the following information for the existing version of the application:
Settings Values Name Enter CurrentWebApp
.Origin type Select App Service from the dropdown. Hostname Enter the hostname of your Web App, for example, webapp-current.azurewebsites.net
.Priority Enter 1
.Weight Enter 75
.Status Select the check box for Enable this origin. Select + Add to add another origin to the origin group. Enter the following information for the new version of the application:
Settings Values Name Enter NewWebApp
.Origin type Select App Service from the dropdown. Hostname Enter the hostname of your Web App, for example, webapp-new.azurewebsites.net
.Priority Enter 1
.Weight Enter 25
.Status Leave Enable this origin unchecked. Note
Initially, set the weight of the current origin higher than the new origin to ensure most traffic is routed to the current origin. Gradually increase the weight of the new origin and decrease the weight of the current origin as you test. The total weight doesn't need to be 100, but it helps visualize traffic distribution. The example sets the existing origin to receive three times as much traffic as the new origin.
Enable session affinity if your application requires it. For more information, see Session affinity.
Note
Session affinity ensures the end user is routed to the same origin after the first request. Enable this feature based on your application and the type of enhancements being rolled out. For major revisions, enable session affinity to keep users on the new codebase. For minor enhancements, you can leave session affinity disabled. When in doubt, enable session affinity.
Health probe settings can be left at the default values. Adjust the probe settings based on your application's needs. For more information, see Health probes.
Under Load balancing settings, enter the following information:
Settings Values Sample size Enter 4
.Successful samples required Enter 3
.Latency sensitivity (in milliseconds) Enter 500
.Note
Set the latency sensitivity to 500 milliseconds (half a second) or higher to ensure both origins are used, as one origin might be faster than the other.
Select Add to add the origin group. Then select Review + create to review the settings of your Front Door profile. Select Create to create the profile.
Start Blue/Green Deployment
To begin the blue/green deployment, enable the new origin to start routing traffic to it while retaining the option to revert to the old origin if necessary.
Once the Front Door profile is created, navigate to the origin group you set up earlier. Select the new origin and check Enable this origin to start routing traffic to it.
Monitor the new origin to ensure it functions correctly. Gradually increase the weight of the new origin while decreasing the weight of the old origin as you gain confidence in the new origin's performance. Continue adjusting the weights until all traffic is routed to the new origin.
If any issues arise with the new origin, disable it to route all traffic back to the old origin. This allows you to address and resolve issues without affecting users.