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.
Before you begin
Section titled โBefore you beginโ- 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
.
Recommended: Use a subdomain with CNAME
Section titled โRecommended: Use a subdomain with CNAMEโExample: www.example.com
-> victorious-beach-0123456789.azurestaticapps.net
.
Steps:
- In Azure Portal -> your Static Web App -> Custom domains -> Add.
- Enter
www.example.com
and choose CNAME validation. - Azure shows a target hostname (your SWA default hostname).
- In your DNS provider, create a CNAME:
- Name/Host:
www
- Type:
CNAME
- Value/Target:
<app-name>.azurestaticapps.net
- Name/Host:
- Save DNS; wait for propagation; click Validate/Next in Azure.
- Azure issues and attaches an SSL certificate automatically.
Alternate: TXT validation then CNAME
Section titled โAlternate: TXT validation then CNAMEโ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.
Apex/root domain options
Section titled โApex/root domain optionsโ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.
Verify and force HTTPS
Section titled โVerify and force HTTPSโ- After validation, open
https://www.example.com
and confirm it loads. - In SWA -> Custom domains, enable โEnforce HTTPSโ.
Troubleshooting
Section titled โTroubleshootingโ- 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.
Provider Example: GoDaddy (Subdomains)
Section titled โProvider Example: GoDaddy (Subdomains)โ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.
- 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).
- 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
(replacedocs
with your subdomain). - TXT Value: Paste the token from Azure.
- TTL: Default (1 hour) is fine -> Save.
- Click Add -> Type:
- Add the CNAME to create the subdomain mapping:
- Click Add -> Type:
CNAME
. - Host:
docs
(orwww
if usingwww.example.com
). - Points to:
your-app-name.azurestaticapps.net
(from Azure). - TTL: Default -> Save.
- Click Add -> Type:
- 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
- Host:
- CNAME:
- Host:
<subdomain>
-> e.g.,www
ordocs
- Value:
<your-app-name>.azurestaticapps.net
- Host:
After Azure validates the DNS records, the domain is attached and HTTPS is managed automatically.