Sitecore Upgrade and Front Door

March 27, 2022

You can leverage Azure Front Door to seamlessly transition between Sitecore environments during an upgrade. By making it simple to transition between Sitecore versions, the upgrade becomes easier to test and you increase trust in it's success. You can also leverage this for the transition to the newer version. By controlling the flow of traffic and slowly increasing load, you can test the new infrastructure and easily roll back if necessary.

For a recent upgrade, I added a ribbon at the top of every page in our non-production Sitecore environment. The ribbon indicated the enviroment, sitecore version, and had a link to switch to the other Sitecore version. See below:

How I Setup Switching Between Sitecore Versions

Clicking the link causes the JavaScript below to execute. It adds a cookie to the user's browser and then refreshes the page. When the page reloads, it is served from a completely different Sitecore environment.

$("a.switch-version").click(function () {
	var expires = new Date();
	expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000));
	document.cookie = 'SitecoreVersion=10; path=/; Secure; SameSite=None; expires=' + expires.toUTCString();
	location.reload();
});
        

To switch the request to a new environment, I setup an Azure Front Door resource with a special routing rule. It was already setup with the hostname and backend in current user, so I added a new backend with Sitecore 10 environment resources. I then added a new rule to our Rules engine configuration that checked the incoming request header for the presence of the Sitecore 10 cookie. If found, it switches to the new Sitecore 10 environment backend. If no matching cookie is found, it continues to the existing Sitecore 9 backend.

Routing Rule if Sitecore 10 Cookie is Found

Go Live

Once the version is ready to go live, you can combine the resources into a single backend.

Front Door Backend Pool Configuration With 2 Sitecore Environments

You can use weights and priority to give preference to one or more backends. However, make sure you read the routing method rules documentation as settings are not considered in certain setups.

By adjusting these settings you can slowly increase the traffic to an environment while reviewing the load and any exceptions through Application Insights. When complete, you can disable or remove the other Sitecore backend.