Skip to main content

How to host a static site on Azure with Front Door

Serve a static site from Azure Blob Storage behind Azure Front Door with global caching and HTTPS. Covers storage setup, upload, and Front Door routing.

Difficulty
Beginner
Duration
40 minutes
Steps
6

Azure Blob Storage can serve a static website directly, and Azure Front Door adds a global content delivery network with HTTPS, caching, and WAF options in front of it. This is the Azure equivalent of S3 plus CloudFront.

Prerequisites

  • An Azure subscription and the Azure CLI signed in.
  • A built static site with an index.html.

Steps

1. Create a storage account

az group create --name rg-site --location eastus
az storage account create --name stsite$RANDOM --resource-group rg-site \
  --sku Standard_LRS --kind StorageV2

2. Enable static website

az storage blob service-properties update --account-name <name> \
  --static-website --index-document index.html --404-document 404.html

This exposes a $web container and a primary web endpoint.

3. Upload content

az storage blob upload-batch --account-name <name> -s ./dist -d '$web'

4. Create a Front Door profile

az afd profile create --profile-name afd-site --resource-group rg-site --sku Standard_AzureFrontDoor
az afd endpoint create --endpoint-name site --profile-name afd-site --resource-group rg-site

5. Add origin and route

Create an origin group, add the storage web endpoint as the origin, then create a route that forwards all paths and enables HTTPS redirect and caching. The route binds the endpoint to the origin group and sets --forwarding-protocol HttpsOnly.

6. Verify HTTPS delivery

Browse to the Front Door endpoint hostname. Front Door provisions a managed TLS certificate automatically for its default domain.

Verification

Load the Front Door hostname over HTTPS and confirm the page renders. Use curl -I and look for an x-cache header indicating an edge hit on repeat requests. Confirm direct HTTP requests redirect to HTTPS.

Next Steps

Attach a custom domain with a managed certificate, enable the Front Door WAF policy, and configure caching rules and compression per content type.

Prerequisites

  • Azure subscription
  • Azure CLI installed
  • Built static site files

Steps

  • 1
    Create a storage account
  • 2
    Enable static website
  • 3
    Upload content
  • 4
    Create a Front Door profile
  • 5
    Add origin and route
  • 6
    Verify HTTPS delivery

Category

Cloud