title | description | services | author | ms.service | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|
Set up a custom domain with Azure DNS in Azure Static Web Apps |
Use Azure DNS to manage your domain name for Azure Static Web Apps |
static-web-apps |
craigshoemaker |
static-web-apps |
how-to |
02/11/2021 |
cshoe |
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 are automatically created for the auto-generated domain name and any custom domains you may add.
This guide demonstrates how to configure your domain name with the www
subdomain. Once this procedure is complete, you can set up an apex domain.
The following procedure requires you to copy settings from an Azure DNS zone you create and your existing static web app. Consider opening the Azure portal in two different windows to make it easier to switch between the two services.
- A custom domain
- An existing Azure DNS zone
- If you don't already have one, refer to Delegate your domain to Azure DNS
Now that your domain is configured for Azure to manage the DNS, you can now link your DNS zone to your static web app.
-
Open the Azure portal.
-
Navigate 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.
-
Return to the DNS zone you created in the Azure portal.
-
Select the + Record set button button.
-
Enter the following values in the Add record set window.
Setting Property Name Enter www Type Select CNAME - Link your subdomain to another account Alias record set Select No. TTL Keep default value. TTL unit Keep default value. Alias Paste in the Static Web Apps generated URL you set aside in a previous step. Make sure to remove the https://
prefix from your URL. -
Select the OK button.
-
Return to your static web app in the portal.
-
Under Settings, select Custom domains.
-
Select the + Add button.
-
In the Enter domain tab, enter your domain name prefixed with www.
For instance, if your domain name is
example.com
, enterwww.example.com
into this box. -
Select the Next button.
-
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 the Add button.
If you get an error saying that the action is invalid, wait 5 minutes and try again.
-
Open a new browser tab and navigate to your domain with the
www
subdomain.After the DNS records are updated, you should see your static web app in the browser. Also, inspect the location to verify that your site is served securely using
https
.
[!div class="nextstepaction"] Set up the apex domain in Azure DNS