Set up a custom domain in Azure Static Web Apps
By default, Azure Static Web Apps provides an auto-generated domain name for your website, but you can point a custom domain to your site. Free SSL/TLS certificates automatically get created for the auto-generated domain name and any custom domains that you might add. This article shows how to configure your domain name with the www
subdomain, using an external provider.
Note
Static Web Apps doesn't support set-up of a custom domain with a private DNS server, hosted on-premises. Consider using an Azure Private DNS zone.
Prerequisites
Consider how you want to support your apex domain. Domain names without a subdomain are known as apex root domains. For example, the domain
www.example.com
is thewww
subdomain joined with theexample.com
apex domain.You create an apex domain by configuring an
ALIAS
orANAME
record or flatteningCNAME
. Some domain registrars, like GoDaddy and Google, don't support these DNS records. If your domain registrar doesn't support all the DNS records you need, consider using Azure DNS to configure your domain.
Note
If your domain registrar doesn't support specialized DNS records and you don't want to use Azure DNS, you can forward your apex domain to the www
subdomain. For more information, see Set up an apex domain in Azure Static Web Apps.
Watch the video
Get your static web app URL
Go to the Azure portal.
Go to your static web app.
From the Overview window, copy the generated URL of your site and set it aside in a text editor for future use.
Create a CNAME record on your domain registrar account
Domain registrars are the services you can use to purchase and manage domain names. Common providers include GoDaddy, Namecheap, Google, Tucows, and the like.
Open a new browser tab and sign in to your domain registrar account.
Go to your domain name's DNS configuration settings.
Add a new
CNAME
record with the following values.Setting Value Type CNAME
Host Your subdomain, such as www Value Paste the domain name you set aside in the text editor. TTL (if applicable) Leave as default value.
Create a CNAME record in Azure Static Web Apps
Return to your static web app in the Azure portal.
Under Settings, select Custom domains > + Add. Select Custom domain on other DNS.
Select + Add.
In the Enter domain tab, enter your domain name prefixed with www, and then select Next.
For instance, if your domain name is
example.com
, enterwww.example.com
.In the Validate + Configure tab, enter the following values.
Setting Value Domain name This value should match the domain name you entered in the previous step (with the www
subdomain).Hostname record type Select CNAME. Select Add.
Azure creates your
CNAME
record and updates the DNS settings. Since DNS settings need to propagate, this process can take up to an hour or longer to complete.When the update completes, open a new browser tab and go to your domain with the
www
subdomain.You should see your static web app in the browser. Also, inspect the location to verify that your site is served securely using
https
.
Next steps
Feedback
Submit and view feedback for