Error adding domain to custom static web app

Ian Morgan 0 Reputation points
2024-01-26T12:15:52.5633333+00:00

I've tried to add both the root domain and a subdomain to my static web app. When adding www as the subdomain I get the error response; "Failed to add custom domain to SWA with error message: CNAME Record is invalid. Please ensure the CNAME record has been created." Yet the CNAME is created in the DNS zone. When trying to add the root I get the error response "domainName is invalid. The domain name given was not found." (Though clearly the DNS zone does exist as it was just selected from the dropdown). I've tried completely recreating the DNS zone and the web app, with no success.

Azure DNS
Azure DNS
An Azure service that enables hosting Domain Name System (DNS) domains in Azure.
603 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
779 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. TP 78,826 Reputation points
    2024-01-26T12:31:20.98+00:00

    Hi Ian,

    To confirm, do you own the domain? If you are using the domain registrar's DNS, did you create the CNAME record in their web portal? Or, if you are using Azure DNS, did you modify the domain in the registrar's portal so that it points to the correct Azure DNS servers?

    For troubleshooting purposes, you can use nslookup on your local machine to make sure the DNS entries are correct. For example, on your local PC you would open a command prompt and enter the following:

    nslookup -q=txt yourdomain.com
    

    The output should show the text record with the verification code that was generated in the Azure portal. Similarly, you would enter command similar to below to verify www:

    nslookup www.yourdomain.com
    

    The output should show record for your Static Web Site unique domain name.

    Please click Accept Answer and upvote if the above was helpful.

    Thanks.

    -TP


  2. brtrach-MSFT 15,351 Reputation points Microsoft Employee
    2024-01-28T05:07:36.0333333+00:00

    @Ian Morgan It seems that you have already created the CNAME record in the DNS zone and you are still getting the error message "CNAME Record is invalid. Please ensure the CNAME record has been created" while adding the subdomain. In this case, you can try verifying the CNAME record by running the following command in the command prompt: nslookup -q=CNAME www.yourdomain.com This command will check if the CNAME record is correctly set up for the subdomain. If the CNAME record is correctly set up, it should return the domain name that you set up in the DNS zone. Regarding the error message "domainName is invalid. The domain name given was not found" while adding the root domain, it could be possible that there is some issue with the DNS zone configuration. You can try deleting the DNS zone and recreating it again. Also, make sure that you have selected the correct DNS zone while adding the custom domain to your Static Web App. If you are still facing issues, please provide more details about the steps you followed to add the custom domain and the DNS zone configuration.