Takeaways from Building a Static Website on Azure

Several official documents have already described clearly about how to build a static website on Azure. By following the step-by-step tutorials, one could successfully create its own website without much to bother with. I have collected the scattered pages together which belong to different components here for better references.

After this step: <storage_account>.<region_code>.web.core.windows.net (primary endpoint) is created.

  • https://docs.microsoft.com/en-us/azure/storage/blobs/storage-custom-domain-name (option I)
    This is an easier option for one to enable custom domain by adding a CNAME record in one’s www subdomain to direct traffic to the blob. However, this does NOT allow one to either access the static website via the root domain (without www prefix) or secure the website with HTTPS. Since my goal is to achieve both, an Azure CDN is required.

After this step: CNAME record www.<domain_name>.<domain> -> <storage_account>.<region_code>.web.core.windows.net (primary endpoint) is created.

  • https://docs.microsoft.com/en-us/azure/cdn/cdn-storage-custom-domain-https (option II)
    The reasons of using Azure CDN are straightforward - support HTTPS and rules engine for redirection. This is the tutorial describing how to access storage blobs using an Azure CDN custom domain over HTTPS, which links to multiple documents below:

    After this step: <endpoint_name>.azureedge.net is created.

    • https://docs.microsoft.com/en-us/azure/dns/dns-delegate-domain-azure-dns
      This one talks about adding a CNAME record mapping to the destination CDN endpoint and associate the domain with the CDN endpoint. However, what is missing here is how to map the root domain to the endpoint. While a CNAME record cannot be placed on a root domain, an A record could. One piece of information sit elsewhere illustrates how to point zone apex to Azure CDN endpoints. With the help of the A record, one can access the site using domain without www prefix.

    After this step: A record www.<domain_name>.<domain> -> <endpoint_name>.azureedge.net is created; A record <domain_name>.<domain> -> <endpoint_name>.azureedge.net is also created;

    • https://docs.microsoft.com/en-us/azure/cdn/cdn-custom-ssl
      This is a simple manual of configuring HTTPS. The note left here is that CDN-managed certificates are not available for root domains. Since HTTPS is already available for www subdomain, redirection with the rules engine could be an easy choice.

    After this step: HTTPS on www.<domain_name>.<domain> is enabled; HTTP 301 HTTP -> HTTPS is enabled.

    After this step: HTTP 301 <domain_name>.<domain> -> www.<domain_name>.<domain> is enabled.

After setting everything up, the redirection chain is ready.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
>>> http://cheng.st

> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------

Status: 301 Moved Permanently
Code: 301
Location: https://cheng.st/
Server: Microsoft-IIS/10.0

>>> https://cheng.st/

> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------

Status: 301 Moved Permanently
Code: 301
Location: https://www.cheng.st/
Server: Microsoft-IIS/10.0

>>> https://www.cheng.st/

> --------------------------------------------
> 200 OK
> --------------------------------------------

Status: 200 OK
Code: 200
Server: Windows-Azure-Web/1.0 Microsoft-HTTPAPI/2.0