Search code examples
azurednsazure-cdn

Azure DNS Config for Custom Root Domain - CDN not being used


I am having problems with my Azure static website not using the CDN that is set up. I have been looking as the Q&As here and also Microsoft docs but I still can't see what I have done wrong. I have spent hours trying to resolve it and think I am down to guessing now.

Azure DNS
Microsoft Standard CDN
Custom Root Domain      example.com
CDN End Point           https://example.azureedge.net/

So basically the setup is Namecheap Domain with Custom DNS being handled in Azure with the following records.

|          Name          | Type         | TTL         | Value                                       | Alias   resource type     | Alias target     |
|:----------------------:|--------------|-------------|---------------------------------------------|---------------------------|------------------|
|             @          |     A        |     3600    |         -                                   |     Azure CDN             |     example      |
|     cdnverify.alias    |     CNAME    |     3600    |         cdnverify.example.azureedge.net     |                           |                  |
|     cdnverify          |     CNAME    |     3600    |         cdnverify.example.azureedge.net     |                           |                  |
|     cdnverify.www      |     CNAME    |     3600    |         cdnverify.example.azureedge.net.    |                           |                  |
|     www                |     CNAME    |     7200    |         example.azureedge.net               |                           |                  |
|     example.com        |     CNAME    |     300     |         example.azureedge.net               |                           |                  |

GTMetrix shows that my domain is not using a CDN but does (obv.) when i test directly to the end point https://example.azureedge.net/

Am I missing DNS records or do I just have them set up incorrectly? I am at a loss as to what is serving my content as there aren't any references to anything other than the CDN endpoint.

Many Thanks in Advance


Solution

  • As I can see there are two extra DNS records according to your requirements that you want to add custom domains www.example.com and example.com. You can remove it.

    cdnverify.alias | CNAME | 3600 | cdnverify.example.azureedge.net

    example.com        |     CNAME    |     300     |         example.azureedge.net
    

    When you add an alias record for root domain example.com in Azure DNS. enter image description here

    It will generate a @ name A record and cdnverify name CNAME record.

    enter image description here

    In addition, you could clear cached content on the CDN edge servers by purging the CDN endpoint when you validate it. For more information, see Purge an Azure CDN endpoint.