Set up a custom domain with Azure DNS in Azure Static Web Apps
By default, Azure Static Web Apps provides an autogenerated domain name for your website, but you can point a custom domain to your site. Free SSL/TLS certificates are automatically created for the autogenerated domain name and any custom domains you may add.
Suppose you buy the domain example.com
from a domain name registrar and then create a zone with the name example.com
in Azure DNS. You want www.example.com
to point to your Static Web Apps site.
- If you're using an apex domain (a domain without a subdomain, also known as a root domain), see configuring a custom apex domain with Azure DNS.
- If you're using an external DNS provider, see configuring a custom domain with external DNS or configuring a custom apex domain with external DNS.
Prerequisites
- A domain purchased from a domain name registrar and hosted on Azure DNS. For details, see Delegate your domain to Azure DNS.
Map the domain to your website
Now that your domain is hosted on Azure DNS, you can create a CNAME record for www.<your domain>
to point to your Static Web App.
Sign in to the Azure portal.
Enter the name of your static web app in the top search bar, or find the static web app in your resources.
Under Settings, select Custom domains.
Select + Add, then select Custom domain on Azure DNS.
Enter the following values in the Add custom domain on Azure DNS window.
Field name Value DNS zone Select your domain name hosted on Azure DNS Subdomain www The Full domain is updated and should match the desired custom domain name.
Select Add
Static Web Apps makes the necessary adjustments to the DNS zone (including adding a CNAME), then validates the changes are available in the global DNS system.
Warning
If you receive the message CNAME Record is invalid, then check that your DNS zone lists the Microsoft DNS services with your DNS registrar. If you have recently moved the domain to Azure DNS, you may need to wait for DNS propagation before adding the custom domain.
Validate the custom domain
It may take some time for the DNS changes to propagate. The default time for Azure DNS is 1 hour.
Open a new browser and go to your domain (for example, https://www.example.com
). Inspect the location to verify that your site is served securely using https
.