Unable to set custom domain on API gateway (consumption tier): BadRequest on unvalid CNAME, when it's correct

Andrew Connell 141 Reputation points MVP
2022-05-30T21:50:07.85+00:00

Trying to set the custom domain on two Azure API Management resources... both (1) are the only API Management resources in their respective subscription & (2) both are on the consumption tiers. The actual endpoints & operations are working, just unable to set the custom domain.

Using the Azure Portal, selecting the API Management resource, I then selected Custom Domains and select Add & set the following values:

  • Type: Gateway
  • Hostname: api.v[...]s.io
  • Certificate: Managed (preview)

I then added the two DNS records (TXT & CNAME) to my DNS records (hosted in Cloudflare), waited until they were resolving & verified they propagated with a few DNS tools:

206800-screen-shot-2022-05-30-at-42129-pm.png

Back in the portal, I select ADD and SAVE, but I keep getting an error: BadRequest: CNAME record pointing from api.v[..]s.io to apiv[..]sio.azure-api.net was not found..

206779-screen-shot-2022-05-30-at-41618-pm.png

These records were added 10+ hours ago and have shown to have been propagated for a while, but I keep getting this error. After multiple attempts and waiting hours on both resources, I'm at a loss.

The only thing I can think of: these custom domains were previously attached to an Azure Functions resource, but I deleted them prior to adding them to the API Management resources. ... is Azure internally caching those original CNAME DNS entries that pointed to the Azure Function resource previously (and thus, the CNAME pointer was different), and even though they've been updated, Azure hasn't updated its internal DNS?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,397 questions
{count} votes

Accepted answer
  1. JananiRamesh-MSFT 29,251 Reputation points
    2022-06-03T06:34:27.09+00:00

    @Andrew Connell As of now to create a Custom domain for an APIM instance deployed in Consumption sku requires all the following values and use them to configure DNS

    • CNAME record
    • TXT record
      apimuid.[customdomain] TXT set to the value specified in the portal
      asuid.[customdomain] TXT which you don't get from the portal to get this value either you should create a support ticket or reach out to us in Q&A forum.

    Work item has been created and fix will be deployed soon. we will update the documentation to add additional steps for Consumption SKU.

    Do let me know if you have any queries.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. yoku 0 Reputation points
    2025-04-04T15:30:27.4566667+00:00

    We had been faced with the same issue for 15 hours.

    Here is my story.

    • There was CNAME record point to another host.
    • There are TXT record required by API Management.
    • I changed the CNAME record to point to API Management gateway.
    • I save the custom domain.
    • API Management says CNAME record not found.

    Is this TTL problem? I think NO. I changed TTL of the CNAME record to 5 minutes 2 days ago.

    Now, I resolve it. How to is following.

    1. Update the CNAME record required by API Management.
    2. Create a TXT record required by API Management.
    3. Configure Custom domain, and hit [Save] button.
    4. Delete the CNAME record. (Not kidding you)
    5. After a while, Custom domain (hostnameConfigurations) is saved successfully.
    6. Re-create the CNAME record.

    Have a nice weekend! Thanks!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.