Skip to content

Azure Static Web Apps Custom Domain Configuration | Complete Guide

This comprehensive guide walks you through adding a custom domain to your Azure Static Web App, including DNS configuration, SSL certificate setup, and troubleshooting common issues.

Azure Static Web Apps provides free SSL certificates and global CDN distribution when you configure custom domains. This guide covers everything you need to know to set up your custom domain successfully.

  • ✅ How to add and verify custom domains in Azure Portal
  • ✅ DNS configuration for popular domain registrars
  • ✅ Automatic SSL certificate provisioning
  • ✅ Domain verification methods
  • ✅ Troubleshooting common configuration issues
  • ✅ Best practices for domain management

Before starting, ensure you have:

  • 🔹 An active Azure subscription
  • 🔹 An existing Azure Static Web App
  • 🔹 A registered domain name
  • 🔹 Access to your domain’s DNS settings

🚀 Step 1: Prepare Your Azure Static Web App

Section titled “🚀 Step 1: Prepare Your Azure Static Web App”
  1. Navigate to Azure Portal: Go to portal.azure.com
  2. Find Your Static Web App: Search for your Static Web App resource
  3. Check Deployment Status: Ensure your app is deployed and running
Terminal window
# Verify your app is accessible via the default URL
curl -I https://your-app-name.azurestaticapps.net

Record the following information:

  • Resource Group Name: my-static-app-rg
  • Static Web App Name: my-awesome-webapp
  • Default URL: https://my-awesome-webapp.azurestaticapps.net

🔧 Step 2: Add Custom Domain in Azure Portal

Section titled “🔧 Step 2: Add Custom Domain in Azure Portal”
  1. Open Azure Portal: Go to your Static Web App resource
  2. Select Settings: In the left navigation panel
  3. Choose Custom domains: Click on the Custom domains option
  1. Click ’+ Add’: Select the Add custom domain button
  2. Enter Domain Name: Type your custom domain (e.g., www.yoursite.com)
  3. Choose Domain Type:
    • Custom domain on Azure DNS: If using Azure DNS
    • Custom domain on other DNS: For external DNS providers
Domain name: yourdomain.com
Domain type: Custom domain on other DNS
Domain name: www.yourdomain.com
Domain type: Custom domain on other DNS

Option C: Custom Subdomain (app.yourdomain.com)

Section titled “Option C: Custom Subdomain (app.yourdomain.com)”
Domain name: app.yourdomain.com
Domain type: Custom domain on other DNS

Azure will provide specific DNS records that you need to add to your domain registrar. The exact records depend on your configuration.

A Record:

Type: A
Name: @
Value: [IP Address provided by Azure]
TTL: 3600

TXT Record (for verification):

Type: TXT
Name: @
Value: [Verification string provided by Azure]
TTL: 3600

CNAME Record:

Type: CNAME
Name: www (or app)
Value: your-app-name.azurestaticapps.net
TTL: 3600

TXT Record (for verification):

Type: TXT
Name: _dnsauth.www (or _dnsauth.app)
Value: [Verification string provided by Azure]
TTL: 3600
Section titled “3.2 DNS Configuration by Popular Registrars”
  1. Log into GoDaddy: Visit godaddy.com and sign in
  2. Manage DNS: Go to My Products → All Products and Services → DNS
  3. Add Records:
# For subdomain setup
Type: CNAME
Host: www
Points to: your-app-name.azurestaticapps.net
TTL: 1 Hour
Type: TXT
Host: _dnsauth.www
TXT Value: [Azure verification string]
TTL: 1 Hour
  1. Access Domain List: Log in and go to Domain List
  2. Manage Domain: Click Manage next to your domain
  3. Advanced DNS: Navigate to Advanced DNS tab
  4. Add New Record:
# For subdomain setup
Type: CNAME Record
Host: www
Value: your-app-name.azurestaticapps.net
TTL: Automatic
Type: TXT Record
Host: _dnsauth.www
Value: [Azure verification string]
TTL: Automatic
  1. Open Cloudflare Dashboard: Go to dash.cloudflare.com
  2. Select Your Domain: Click on your domain name
  3. DNS Settings: Go to DNS → Records
  4. Add Records:
# For subdomain setup
Type: CNAME
Name: www
Content: your-app-name.azurestaticapps.net
Proxy status: DNS only (gray cloud)
TTL: Auto
Type: TXT
Name: _dnsauth.www
Content: [Azure verification string]
TTL: Auto
  1. AWS Console: Navigate to Route 53 → Hosted zones
  2. Select Domain: Click on your domain
  3. Create Record Set:
{
"Name": "www.yourdomain.com",
"Type": "CNAME",
"TTL": 300,
"Value": "your-app-name.azurestaticapps.net"
}
{
"Name": "_dnsauth.www.yourdomain.com",
"Type": "TXT",
"TTL": 300,
"Value": "[Azure verification string]"
}

  1. Return to Azure Portal: Go back to your Static Web App → Custom domains
  2. Click Validate: After adding DNS records, click the Validate button
  3. Wait for Verification: This process can take up to 48 hours

Monitor the verification status:

Status Options:
✅ Validated - Domain is ready to use
⏳ Validating - Verification in progress
❌ Failed - DNS records need correction
⚠️ Pending - Waiting for DNS propagation

Use these tools to verify DNS propagation:

Terminal window
# Check DNS propagation globally
nslookup www.yourdomain.com 8.8.8.8
# Verify TXT record
nslookup -q=TXT _dnsauth.www.yourdomain.com
# Use online tools
# Visit: https://dnschecker.org
# Enter: www.yourdomain.com

🔒 Step 5: SSL Certificate Configuration

Section titled “🔒 Step 5: SSL Certificate Configuration”

Azure automatically provisions SSL certificates for verified domains:

  • Certificate Authority: DigiCert
  • Validity Period: 3 months (auto-renewed)
  • Certificate Type: Domain Validated (DV)

Check certificate status in Azure Portal:

Certificate States:
✅ Ready - SSL certificate active
⏳ Requesting - Certificate being provisioned
❌ Failed - Certificate request failed
🔄 Renewing - Certificate being renewed

Enable HTTPS redirect in your Static Web App configuration:

staticwebapp.config.json:

{
"routes": [
{
"route": "/*",
"headers": {
"Strict-Transport-Security": "max-age=31536000; includeSubDomains"
}
}
],
"globalHeaders": {
"content-security-policy": "default-src https: 'unsafe-eval' 'unsafe-inline'; object-src 'none'"
}
}

Test your custom domain configuration:

Terminal window
# Test HTTP to HTTPS redirect
curl -I http://www.yourdomain.com
# Test HTTPS response
curl -I https://www.yourdomain.com
# Test SSL certificate
openssl s_client -connect www.yourdomain.com:443 -servername www.yourdomain.com
  1. Open Browser: Navigate to https://www.yourdomain.com
  2. Check SSL Certificate: Click the lock icon in address bar
  3. Verify Certificate Details:
    • Issued by: DigiCert
    • Valid dates
    • Subject Alternative Names

Test global CDN performance:

Terminal window
# Test from different locations
curl -w "@curl-format.txt" -o /dev/null -s https://www.yourdomain.com
# Create curl-format.txt:
echo "time_namelookup: %{time_namelookup}s
time_connect: %{time_connect}s
time_appconnect: %{time_appconnect}s
time_pretransfer: %{time_pretransfer}s
time_redirect: %{time_redirect}s
time_starttransfer: %{time_starttransfer}s
time_total: %{time_total}s" > curl-format.txt

Configure multiple domains for the same Static Web App:

Primary Domain: www.yourdomain.com
Additional Domains:
- yourdomain.com (redirect to www)
- app.yourdomain.com
- staging.yourdomain.com

Configure different subdomains for different environments:

staticwebapp.config.json:

{
"routes": [
{
"route": "/api/*",
"allowedRoles": ["authenticated"]
},
{
"route": "/*",
"serve": "/index.html",
"statusCode": 200
}
],
"responseOverrides": {
"404": {
"rewrite": "/404.html",
"statusCode": 404
}
}
}

Configure different domains for different environments:

Terminal window
# Production
az staticwebapp hostname set \
--name my-production-app \
--hostname www.yourdomain.com
# Staging
az staticwebapp hostname set \
--name my-staging-app \
--hostname staging.yourdomain.com

Symptoms:

  • Domain verification fails
  • DNS changes not reflected globally

Solutions:

Terminal window
# Check TTL values
dig www.yourdomain.com
# Wait for global propagation (up to 48 hours)
# Use lower TTL values (300-3600 seconds)
# Verify with multiple DNS servers
nslookup www.yourdomain.com 8.8.8.8
nslookup www.yourdomain.com 1.1.1.1

Issue 2: SSL Certificate Provisioning Fails

Section titled “Issue 2: SSL Certificate Provisioning Fails”

Symptoms:

  • Certificate status shows “Failed”
  • HTTPS not working after domain verification

Solutions:

  1. Verify DNS Records: Ensure CNAME/A records are correct
  2. Check Domain Validation: TXT records must be exactly as provided
  3. Remove and Re-add: Delete domain and add again
  4. Contact Support: For persistent issues

Symptoms:

  • Browser shows “Too many redirects” error
  • Site not accessible

Solutions:

// Check staticwebapp.config.json for conflicting redirects
{
"routes": [
{
"route": "/old-path",
"redirect": "/new-path",
"statusCode": 301
}
]
}

Symptoms:

  • Domain verification fails with CNAME conflicts
  • Multiple CNAME records for same subdomain

Solutions:

  1. Remove Conflicting Records: Delete existing CNAME records
  2. Use Correct Format: Ensure CNAME points to your-app.azurestaticapps.net
  3. Check Subdomain: Verify you’re configuring the right subdomain
Terminal window
# Check DNS resolution
dig +trace www.yourdomain.com
# Test SSL certificate
echo | openssl s_client -connect www.yourdomain.com:443 2>/dev/null | openssl x509 -noout -dates
# Verify HTTP headers
curl -I https://www.yourdomain.com
# Check Azure CLI status
az staticwebapp show --name my-app --resource-group my-rg

  1. Enable HSTS: Add Strict-Transport-Security headers
  2. Use Content Security Policy: Implement CSP headers
  3. Regular Certificate Monitoring: Monitor SSL certificate expiration
  4. DNS Security: Use DNSSEC if supported by registrar
  1. Use CDN-Friendly TTL: Set appropriate TTL values (3600-86400 seconds)
  2. Minimize DNS Lookups: Reduce number of subdomains
  3. Enable Compression: Configure gzip/brotli compression
  4. Optimize Images: Use WebP format and responsive images
  1. Set Up Alerts: Monitor domain and certificate status
  2. Regular Testing: Perform monthly accessibility tests
  3. Update Documentation: Keep DNS configurations documented
  4. Backup Configurations: Document all DNS settings

# Create monitoring script
#!/bin/bash
DOMAIN="www.yourdomain.com"
RESPONSE_TIME=$(curl -w "%{time_total}" -o /dev/null -s https://$DOMAIN)
STATUS_CODE=$(curl -w "%{http_code}" -o /dev/null -s https://$DOMAIN)
echo "Domain: $DOMAIN"
echo "Response Time: ${RESPONSE_TIME}s"
echo "Status Code: $STATUS_CODE"
if [ $STATUS_CODE -eq 200 ]; then
echo "✅ Domain is healthy"
else
echo "❌ Domain issue detected"
fi
Terminal window
# Check certificate expiration
echo | openssl s_client -servername $DOMAIN -connect $DOMAIN:443 2>/dev/null | openssl x509 -noout -dates

  • Azure Static Web App deployed and running
  • Custom domain added in Azure Portal
  • DNS records configured at registrar
  • Domain verification completed
  • SSL certificate provisioned
  • HTTPS redirect enabled
  • Domain accessibility tested
  • Performance optimized
  • Monitoring configured
  1. DNS Propagation: Allow up to 48 hours for global DNS propagation
  2. Certificate Automation: Azure handles SSL certificate provisioning automatically
  3. Multiple Domains: You can configure multiple custom domains per Static Web App
  4. Global CDN: Custom domains benefit from Azure’s global CDN network
  5. Free SSL: SSL certificates are provided free with custom domains

After successful domain configuration:

  1. Configure Analytics: Set up Application Insights or Google Analytics
  2. Implement Monitoring: Set up uptime and performance monitoring
  3. Optimize Performance: Configure caching and compression
  4. Plan Scaling: Consider multiple environments and CI/CD integration

Need help? Check the troubleshooting section above or reach out to the Azure community for support!