3

I have a custom domain www.abc.com configured for web app webapp-a, and I'd like to transfer it to webapp-b without downtime.

If I try to add the domain to webapp-b, I am getting

The host name www.abc.com is already assigned to another Azure website: webapp-a

It there a way to let webapp-a continues to serve the requests, until the DNS cache expires?

Edit: The domain has IP based SSL binding, and the DNS is caching the virtual IP.

fszlin
  • 749
  • 7
  • 15

3 Answers3

2

I faced the same issue, and was able to solve it in a tricky way.

I created new App Service Plan (previously known as Web Hosting Plan), and assigned "new" Web App to it (you can do it via new portal, or you can create Service Plan during Web App creation).

Then, I was able to assign the same host name to Web Apps in different hosting plans.

Thinking about this, I feel it logical: most probably Service Plan is mapped to physical IIS machine, and you cannot have two sites with the same host name in the same IIS for the obvious reason.

After migration from one DNS to another is done, you can remove unused Service Plan (as you basically pay for each separately).

Lanorkin
  • 7,310
  • 2
  • 42
  • 60
  • this solution doesn't work for me. I can't add the same hostname despite different app service plans in different regions. why? – Harry Apr 08 '16 at 14:40
  • @Harry I'm in the same boat as you, did you manage to solve your issue? – John Leidegren Mar 01 '17 at 18:19
  • actually we had a downtime. :) but i think one solution could be to install a [Transfer Manager](https://learn.microsoft.com/en-us/azure/traffic-manager/traffic-manager-how-traffic-manager-works) first and afterwards use his failover feature. – Harry Mar 02 '17 at 19:31
  • @JohnLeidegren as I said that was one of millions trickery non-obvious things you have to do with azure, which you cannot ever be sure in. I was sitting in exactly the same boat and was tearing my hair to achieve no-downtime. I can just advice playing with for example different costs for app service plans. Doing it now I would be writing ticket to azure, but that days I had to do it "just now!", so had no time to communicate with support; from my experience such tickets being solved from weeks to months – Lanorkin Mar 03 '17 at 05:09
  • @Lanorkin well I can share with you first hand experience how things wen't down yesterday. Azure validates DNS ownership in a very stupid way, so I couldn't have both the new and old site configured to use the same DNS name, I'm guessing this has to do with Azure internals anyway, when I tried to move the custom domains I had to remove their bindings first, which resulted in down time. But when I did this with the production site I got errors and now the main site was down and I was getting all kinds of errors from Azure... (to be continued) – John Leidegren Mar 03 '17 at 11:45
  • I immediately opened a business critical support ticket and then went on trying to fix the issue, turns out I had to remove all custom domains and then add them all back for it to work. I had migrated some before as a test run but now this suddenly didn't work. Anyway problem fixed and about 30 minutes later. Azure calls me, (I made a note in the ticket stressing the urgency and that the site was down), first question, How are you doing, sir today? In this very moment I wanted to just hang up. I explained that it would be better if Azure didn't return errors and that my issue was resolved... – John Leidegren Mar 03 '17 at 11:48
  • The operator had very bad English accent and I could hardly make out what she was saying. Anyway, I think this is why you need Azure traffic manager. Without you'll be stuck with these kinds of migration pains. The traffic manager should be fracking standard. – John Leidegren Mar 03 '17 at 11:49
1

According to a blog post by the Azure App Service Team in June 2017, it would appear that Azure now supports adding the same custom domain to multiple web apps:

There are scenarios where a customer would like to add the same hostname to multiple web apps in the same subscription, having a geo distributed website is one example. Our custom hostname feature allows you to bypass validation for hostnames that have already been validated. You only need to verify domain ownership when you add a hostname for the first time. For all other apps in the same subscription, you can add the same hostname without creating any DNS records.

You can read the entire blog post at https://blogs.msdn.microsoft.com/appserviceteam/2017/06/21/custom-hostnames-with-app-service/. The quote above was taken from the Adding the same custom hostname to multiple web apps section.

This should help in scenarios such as this where you want to transfer a custom domain name from one web app to another. You can simply add the same custom domain name to both web apps, add any required SSL bindings, and then change the DNS to point to the new web app. As the DNS change propagates, traffic should gradually move over to the new web app without any downtime.

I've tested this myself in the North Europe region and had no problems. Both web apps were in different App Service Plans. I have not tested this scenario with both web apps in the same App Service Plan. Bear in mind that if you're using IP addresses/A records in your DNS, you'd need both web apps to have different IP addresses for the DNS to be able to differentiate between your web apps.

Sam W
  • 11
  • 1
  • 2
  • I always thought that this would work out if the app services were in different plans because I thought different plans meant different machines/VMs/IIS instances etc, but it seems not. I have two different app service plans each with one app service, in the same region, but I can only add custom domain X to one of the app services. Trying to add the second gives the "already in use" error. If I nslookup the two different app service names (in different plans) I get the same IP.. Strange! – Caius Jard Mar 04 '20 at 14:49
0

Try assigning the domain to Azure Traffic Manager and have the traffic manager forward the request to the second site. Azure Traffic Manager and Web Apps are two different systems so you might be able to assign the same domain name to a web app and a traffic manager.

Once the DNS cache has expired remove the domain from the old Azure web app and add it to the new one, then finally delete the Traffic Manager account.

Option 2

Set the TTL to something very small, say 5 seconds (I believe your hostname provider should let you set that up), wait for the new TTL to propagate through all the caches. Then switch the custom domain from one app to another, and set the TTL back to it's original value.

This will result in just a few seconds of downtime for any customers, but if you do it at a low-traffic time the effect shouldn't be too bad.

Zain Rizvi
  • 23,586
  • 22
  • 91
  • 133
  • Just tested a bit, I need to move the domain to webapp-b, or it won’t handle the requests. And as soon as I remove the domain from the webapp-a, it will stop serving the requests. So I think if a client is hitting webapp-a directly because of DNS cache, a 404 will be issued. I should have mention that the domain has IP-based SSL binding, which may has impact on how the clients are being routed. – fszlin Aug 21 '15 at 20:30