Azure – Fixing Domain Ownership Error with CNAME Records

azurecloudflare

I am trying to set up the urls https://www.mywebsite.net.au and https://mywebsite.net.au to work for my Azure App Service using with Cloudflare.

Where mywebsite represents my web site name.

Currently when I go to this url I get a 404 error.

In Azure, In Custom Domains, when I try to add a host name for www.jobtalk.net.au and click validate I get a Domain Ownership error
"No CNAME records were found. Please add a CNAME record pointing to sbdwebapp.azurewebsites.net"

If I try adding a CNAME for www with the value sbdwebapp.azurewebsites.net

I get an error message:

n A, AAAA or CNAME record already exists with that host. (Code: 81053)

I am trying to follow
https://docs.microsoft.com/en-us/azure/app-service-web/app-service-web-tutorial-custom-domain#cname

DNS showing in CloudFlare

Best Answer

The problem is due to a conflict between CloudFlare's CNAME flattening and Azure's CNAME verification. The CNAME flattening essentially returns A records, which speeds up DNS resolution and is a good idea in general. However, Azure's CNAME verification only verifies CNAME records.

The best workaround I've found is to:

  1. Disable CloudFlare's HTTP proxying (click the orange cloud on that CNAME record so that it turns grey); this also disables CNAME flattening for that record.
  2. Check your host on dig until you see the CNAME records show up.
  3. Verify your CNAME host on the Azure portal.
  4. Re-enable CloudFlare's HTTP proxying (click the grey cloud on that CNAME record so it turns orange).

This allows you to verify on Azure and still take advantage of CloudFlare's CDN.

Related Topic