Set up a custom domain 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 automatically get created for the autogenerated 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.

There are multiple methods of configuring a custom domain for use with Static Web Apps:

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

  • You must be able to create a CNAME record on your DNS domain using the tools that your DNS service or domain registrar provides.

Watch the video

Get your static web app URL

  1. Go to the Azure portal.

  2. Go to your static web app.

  3. 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 services you can use to purchase and manage domain names. To find a domain registrar, see the ICANN list of accredited registrars.

  1. Open a new browser tab and sign in to your domain registrar account.

  2. Go to your domain name's DNS configuration settings.

  3. 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

  1. Return to your static web app in the Azure portal.

  2. Under Settings, select Custom domains > + Add. Select Custom domain on other DNS.

  3. Select + Add.

  4. 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, enter www.example.com. Screenshot showing sequence of steps in add custom domain form.

  5. In the Validate + add 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.
  6. Select Add.

    Azure validates that the CNAME record was created correctly and is available in the global DNS system. Propagation depends on the time to live (TTL) for your domain and may take several days. If the validation fails, return to add the custom domain later.

  7. 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. Inspect the location to verify that your site is served securely using https.