Skip to content

Add Custom Domain to Static Web Apps

Add Custom Domain to Azure Static Web Apps

Section titled “Add Custom Domain to Azure Static Web Apps”

Map your own domain (e.g., www.example.com) to your Static Web App and get managed TLS.

  • You own the domain and can edit DNS at your registrar (GoDaddy, Cloudflare, Route 53, etc.).
  • Your SWA deployment is live and reachable at https://<app-name>.azurestaticapps.net.

Example: www.example.com -> victorious-beach-0123456789.azurestaticapps.net.

Steps:

  1. In Azure Portal -> your Static Web App -> Custom domains -> Add.
  2. Enter www.example.com and choose CNAME validation.
  3. Azure shows a target hostname (your SWA default hostname).
  4. In your DNS provider, create a CNAME:
    • Name/Host: www
    • Type: CNAME
    • Value/Target: <app-name>.azurestaticapps.net
  5. Save DNS; wait for propagation; click Validate/Next in Azure.
  6. Azure issues and attaches an SSL certificate automatically.

If your DNS provider requires validation, Azure may ask for a TXT record first. Add the TXT record, validate, then add the CNAME as above.

Static Web Apps works best with subdomains (www). For root (example.com):

  • If your DNS supports ALIAS/ANAME at root, point it to <app-name>.azurestaticapps.net.
  • If not, use your DNS provider’s URL redirect from example.com -> www.example.com.
  • Alternatively, place Azure Front Door in front to handle apex domains with managed certificates.
  • After validation, open https://www.example.com and confirm it loads.
  • In SWA -> Custom domains, enable “Enforce HTTPS”.
  • DNS not propagated: Check with nslookup www.example.com or online DNS tools.
  • Conflicting records: Remove existing A/AAAA records for the same host when using CNAME.
  • Multiple environments: Staging environments have their own default hostnames; map the right one.
  • Certificate pending: Usually resolves within minutes; revalidate if it stalls.

The fastest approach is to map a subdomain (e.g., www.example.com or docs.example.com) using a CNAME record. Azure may ask you to add a TXT record for validation first.

  1. In Azure (collect values)
  • Go to your Static Web App -> Custom domains -> Add.
  • Enter your subdomain, e.g., docs.example.com.
  • Copy the SWA default hostname (CNAME target): your-app-name.azurestaticapps.net.
  • If Azure shows TXT validation, note the TXT host and value (e.g., host asuid.docs, value: token).
  1. In GoDaddy (add DNS records)
  • Go to GoDaddy -> My Products -> Domains -> -> DNS.
  • If TXT validation is requested by Azure first:
    • Click Add -> Type: TXT.
    • Host: asuid.docs (replace docs with your subdomain).
    • TXT Value: Paste the token from Azure.
    • TTL: Default (1 hour) is fine -> Save.
  • Add the CNAME to create the subdomain mapping:
    • Click Add -> Type: CNAME.
    • Host: docs (or www if using www.example.com).
    • Points to: your-app-name.azurestaticapps.net (from Azure).
    • TTL: Default -> Save.
  1. Back in Azure (validate and finish)
  • In the custom domain wizard, click Validate/Next.
  • Azure verifies TXT (if present) and the CNAME.
  • Once validated, Azure issues a certificate automatically.
  • Open the new domain and enable “Enforce HTTPS”.

Quick Reference: Records You’ll Add for a Subdomain

Section titled “Quick Reference: Records You’ll Add for a Subdomain”
  • TXT (only if Azure requests validation):
    • Host: asuid.<subdomain> -> e.g., asuid.www
    • Value: The token shown by Azure
  • CNAME:
    • Host: <subdomain> -> e.g., www or docs
    • Value: <your-app-name>.azurestaticapps.net

After Azure validates the DNS records, the domain is attached and HTTPS is managed automatically.