Search code examples
asp.netazureazure-web-app-serviceazure-traffic-manager

Diverting web traffic from one Azure Web app to another without downtime


I have two Azure web apps:

  • webapp1.azurewebsites.net
  • webapp2.azurewebsites.net

webapp1 is my live website, which is configured with a custom domain, www.example.com.

I want to divert all incoming traffic so that it goes to webapp2, rather than webapp1.

My plan to do this was:

  1. Add the custom domain 'www.example.com' to webapp2.
  2. Change the DNS CNAME record for www.example.com so that it points to webapp2.azurewebsites.net (instead of webapp1.azurewebsites.net).

However, this approach doesn't work; When I try to add the custom domain name to webapp2 using portal.azure.com, I get the error: 'The host name www.example.com' is already assigned to another Azure website'.

It's important to ensure that there is no downtime in this transition, so removing the custom domain name from webapp1 before adding it to webapp2 isn't an option.

Any ideas on how I can solve this problem?


Solution

  • As per the previous answer, you can use Azure Traffic Manager to control traffic between Web Apps. However, you will still face the problem of registering the custom domain name against both web apps. The Traffic Manager documentation contains further information about how to do this - see "Can I use Traffic Manager with more than one Web App in the same region?" in the FAQ section here.

    The key point is that if the Web Apps are in the same region, then they need to be in different scale units. The instructions linked above show how to check which scale unit your Web App is in. You can't control the scale unit when deploying the Web App, but if you submit a Support ticket you may be able to have your Web Apps deployed to different scale units by Azure Support.