Repository navigation
Azure Static Website
This article describes creation of an Azure static website with a custom domain backed up by Azure DNS Zone and Azure CDN provided HTTPS certificates.
Azure storage (v2) supports hosing a static website off of a blob storage.
- The storage name has to be unique across the whole Azure
- Create a new resource group for the storage (e.g., "web1-rg")
- Set the name of the storage (e.g., "web1tkdev")
- Select region (e.g., "Europe (West Europe)")
- Keep everything on default, optionally removing
Enable soft deletefor blobs, containers and file shares - Create the storage
- Navigate to the storage resource
- Select "Static website"
- Select "Enable"
- Specify "Index document name" to "index.html"
- Optionally, specify "Error document name" to "error.html"
Content can be uploaded either via the Azure Web UI, or the Azure CLI. To enable uploading content through the Azure CLI, set the access control first.
- Navigate to Access Control (IAM)
- Select "Role assignments" tab
- Click on "Add" and select "Add role assignment" from the dropdown
- Select "Storage Blob Data Contributor" from the built-in roles and click "Next"
- Click "+ Select Members" and select your identity
- Process to "Review + assign"
The static website content is stored in the $web blob. To upload content to this blob from the CLI, run
az storage blob upload-batch --account-name $azStorageName -d '$web' -s $contentPath --pattern '*' --overwrite --validate-content --auth-mode loginTo host the static website with a custom domain with HTTPS support, the easiest way is to use Azure CDN to manage the SSL certificates.
- Navigate to the storage resource
- Select "Azure CDN"
- Use existing CDN presuming you have one (or create new)
- Fill in the "CDN endpoint name" (has to be unique across the
.azureedge.netdomain- As convention, use your custom domain you want to use, replacing dots with hyphens
- [Important] From the "Origin hostname" dropdown, select the "(Static website)" instead of the "(Blob)" option
- Create
At this point, the static website will be accessible on the address specified in the "CDN endpoint name" above (ending in .azureedge.net).
Presuming you have the Azure DNS Zone with a custom domain supported, you can bind custom domain to your static website.
- Navigate to the Azure DNS zone resource you want to use
- Select "+ Record set" at the top
- Fill in the "Name"
- Select "Type" to "CNAME" in the dropdown
- Select "Alias record set" to "Yes"
- Keep "Alias type" to "Azure resource"
- Keep (or select) the Azure subscription
- Set the "Azure resource" to the CDN entry created above
- Keep the TTL settings
- Click "OK"
There will be two CNAME records created. One with the name just created and other one with a cdnverify prefix.
At this moment, the DNS record is set and it just needs to be associated with CDN custom domain.
- Navigate to the CDN resource again
- Select the endpoint corresponding to your static website
- Click on the "+ Custom domain"
- Fill in the domain name of the DNS record set above
Provisioning of the SSL certificate will take up to 10 minutes, after which the Azure storage backed-up static website will be available on the custom domain.