An Azure service that provides a hybrid, multi-cloud management platform for APIs.
APIM issue creating developer portal custom domain
On a standard v2 APIM, whenever we create a custom domain name for Developer portal, it saves succesfully, returns us to the custom domains list and then after about 5 seconds, the new custom domain name simply disappears without explanation. Coming back a few hours later, it is indeed just gone. We have tried multiple times on different days with the same result. There's really no logs or explanation that we can find at least. Any idea?
Azure API Management
-
Ranashekar Guda • 2,905 Reputation points • Moderator
2025-05-13T22:44:44.83+00:00 Hello @David R,
It sounds like you are experiencing an issue with the custom domain configuration for your Developer Portal in Azure API Management (APIM). One possible reason for the custom domain disappearing after being saved could be related to the configuration settings or permissions associated with your API Management instance.To troubleshoot this issue, ensure that the following steps are followed:
- Verify that the custom domain is correctly configured in the Azure portal under the API Management instance.
- Check if the necessary DNS records (such as CNAME and TXT records) are set up properly to point to the API Management service.
- Ensure that the Managed identities option is enabled for your API Management instance, as this can affect the ability to create and maintain custom domains.
- Review the access policies in your Azure Key Vault to confirm that the API Management service has the required permissions to access the certificates used for the custom domain.
- After creating the custom domain, try republishing the Developer portal to see if the changes persist. Sometimes, republishing the portal can help in applying the custom domain changes correctly.
Kindly refer below links:
Failed to update API Management service hostnamesConfigure a custom domain name for your Azure API Management instance
Hope this helps. Do let us know if you any further queries.
-
Ranashekar Guda • 2,905 Reputation points • Moderator
2025-05-14T19:01:09.4666667+00:00 Hello @David R,
Just checking in to see if above information was helpful. If you have any further updates on this issue, please feel free to post back. -
David R • 0 Reputation points
2025-05-14T20:42:37.2833333+00:00 Hello, please see my answers below.
- Verify that the custom domain is correctly configured in the Azure portal under the API Management instance.
- I'm not sure what you mean there. That is what we are trying to configure, the developer portal custom domain name. Like I mentioned, we can create it and save the configuration succesfully, however the dev.portal entry automatically removes itself after a few seconds without us doing anything. For the record, we have been able to configure the custom domain for the gateway without issue.
- Check if the necessary DNS records (such as CNAME and TXT records) are set up properly to point to the API Management service.
- Yes, they are correct. When they are not, we get an error saying so.
- Ensure that the Managed identities option is enabled for your API Management instance, as this can affect the ability to create and maintain custom domains.
- It is enabled.
- Review the access policies in your Azure Key Vault to confirm that the API Management service has the required permissions to access the certificates used for the custom domain.
- Yes, I believe they are correct. Especially since we are using a wildcard certificate in a Keyvault and the gateway custom domain name uses it succesfully.
- After creating the custom domain, try republishing the Developer portal to see if the changes persist. Sometimes, republishing the portal can help in applying the custom domain changes correctly.
- I have tried publishing the portal again and unfortuntely, the problem persists.
Thanks
- Verify that the custom domain is correctly configured in the Azure portal under the API Management instance.
-
Gaurav Kumar • 790 Reputation points • Moderator
2025-05-16T01:27:00.48+00:00 Hi David R,
Following up to check if the issue is resolved or if you need any further assistance. Let me know how it's going!
-
-
Gaurav Kumar • 790 Reputation points • Moderator
2025-05-21T01:27:06.0666667+00:00 Hi David R,
Thanks for the detailed follow-up.
Use ARM or Bicep to apply the custom domain
The portal UI may not retain the configuration unless the backend validation succeeds instantly. Using Infrastructure-as-Code (ARM/Bicep/CLI) bypasses some UI-time validations.
az apim update --name <ApimName> --resource-group <RsrGrpNme> --set hostnameConfigurations='[{ type:"DeveloperPortal", hostname:"dev.<yourdomain>.com", certificateSource:"KeyVault", defaultSslBinding:true, keyVaultId:"<full_cert_secret_URI>", negotiateClientCertificate:false }]'If this succeeds, the domain should stick.
Manually validate TXT ownership record (if required)
Even though wildcard certificates work for Gateway domains, the Developer Portal domain may still require TXT verification:
- Go to your DNS zone
- Add a TXT record:
Name: asuid.dev.<domain>.com Value: <value from domain verification guide or portal prompt>You may not always get prompted, but lack of this can cause silent failure.
Check APIM Diagnostic Logs
Enable diagnostic logs on APIM:
az monitor diagnostic-settings create --resource <APIM_ID> --name apim-logs --workspace <LogAnalyticsId> --logs '[{"category": "GatewayLogs","enabled": true}]'Look for logs under:
ManagementServiceLogs,ApimServiceManagementAuditLogsThere may be an entry showing domain verification rejection.
If Still Failing, try to switch to App Gateway certificate instead of Key Vault-backed (temporarily) and test.
Hope it helps!
If you have any other questions or still running into more issues, let me know in the "comments" and I would be happy to help you.
-
Gaurav Kumar • 790 Reputation points • Moderator
2025-05-21T01:37:42.76+00:00 Hi David R,
Thanks for the detailed follow-up.
Use ARM or Bicep to apply the custom domain
The portal UI may not retain the configuration unless the backend validation succeeds instantly. Using Infrastructure-as-Code (ARM/Bicep/CLI) bypasses some UI-time validations.
az apim update --name <ApimName> --resource-group <RsrGrpNme> --set hostnameConfigurations='[{ type:"DeveloperPortal", hostname:"dev.<domain>.com", certificateSource:"KeyVault", defaultSslBinding:true, keyVaultId:"<full_cert_secret_URI>", negotiateClientCertificate:false }]'If this succeeds, the domain should stick.
Manually validate TXT ownership record (if required)
Even though wildcard certificates work for Gateway domains, the Developer Portal domain may still require TXT verification:
- Go to your DNS zone
- Add a TXT record:
Name: asuid.dev.<domain>.com Value: <value from domain verification guide or portal prompt>You may not always get prompted, but lack of this can cause silent failure.
Check APIM Diagnostic Logs
Enable diagnostic logs on APIM:
az monitor diagnostic-settings create --resource <APIM_ID> --name apim-logs --workspace <LogAnalyticsId> --logs '[{"category": "GatewayLogs","enabled": true}]'Look for logs under:
ManagementServiceLogs,ApimServiceManagementAuditLogsThere may be an entry showing domain verification rejection.
If Still Failing, try to switch to App Gateway certificate instead of Key Vault-backed (temporarily) and test.
Hope it helps!
If you have any other questions or still running into more issues, let me know in the "comments" and I would be happy to help you.
-
David R • 0 Reputation points
2025-05-21T20:02:39.4433333+00:00 I believe we found the cause for this specific problem, but fixing it creates another issue. The problem was that we modified the gateway CNAME after it was added, so it could point to our Application Gateway. It seems adding the Dev Portal custom domain afterwards also checks the CNAME of the gateway for some reason. We had to revert the gateway CNAME to customName.azure-api.net.
Here's where we are a bit confused however. We are trying to implement this scenario :
We have encountered multiple issues, but the biggest one right one is with custom domains. Adding a custom domain forces us to have a CNAME in place pointing to customDomain.azure-api.net - BUT - we need the CNAME to actually hit the FrontEnd of the AppGW. So we change it afterwards to point at the AppGW. Is this how are we supposed to implement this? This part doesn't seem documented.
So, say we do change the CNAME to point at the Application Gateway, it works, but only for some time. Eventually, the backend health fails with this:
The Common Name of the leaf certificate presented by the backend server does not match the Probe or Backend Setting hostname of the application gateway.
Clicking Troubleshoot, we see the Backend Server is back to using default domain/certificate:
Common Name :
*.azurewebsites.net
Issuer :
Microsoft Azure RSA TLS Issuing CA 03
Valid Till :
08/01/2025 12:10:09
and NOT our custom domain.
Please advise. Thanks.
-
Gaurav Kumar • 790 Reputation points • Moderator
2025-05-27T09:48:11.1766667+00:00 Hi David R,
Apologies for the delayed response, I wanted to make sure I thoroughly reviewed your scenario before replying. Thank you for your patience, and I appreciate the detailed context you provided.
When setting up a custom domain for the Developer Portal, APIM checks that the CNAME points to its default endpoint (
*.azure-api.net). If it’s already pointing to Application Gateway, that check silently fails, and the domain is removed from the configuration shortly after saving.Additionally, if the Application Gateway probes APIM using a hostname that doesn’t match the SSL certificate (e.g., it expects
dev.yourdomain.combut receives*.azurewebsites.net), health checks will fail due to a TLS hostname mismatch.Try the below workaround to resolve the issue:
Point CNAME to
*.azure-api.netInitiallyBefore configuring the Developer Portal custom domain, temporarily set the CNAME to point to the default APIM endpoint (
apim-name.azure-api.net). This allows APIM to validate and persist the configuration successfully.Use CLI to Set the Developer Portal Domain
Use the CLI or an ARM template instead of the portal UI to reliably apply the custom domain configuration:
az apim update --name <ApimName> --resource-group <RsrGrpNme> --set hostnameConfigurations='[ { type: "DeveloperPortal", hostname: "dev.yourdomain.com", certificateSource: "KeyVault", keyVaultId: "<KeyVaultSecretUri>", negotiateClientCertificate: false, defaultSslBinding: true } ]'Flip the CNAME to Point to Application Gateway
Once the domain is successfully saved in APIM, you can safely change the DNS CNAME to point to your App Gateway frontend.
Configure App Gateway to Override Hostname
In Application Gateway's HTTP settings:
Override with specific hostname:
dev.yourdomain.comThis ensures the backend request matches the certificate's CN/SAN.
Use a Custom Health Probe
Create a custom probe targeting
https://dev.yourdomain.com/, with expected status codes 200–399, to validate backend health and SSL.Additional Tips:
- Use
curl -v https://dev.yourdomain.comfrom a VM inside the VNet to verify which certificate APIM is returning. - Enable diagnostics in both App Gateway and APIM to troubleshoot validation or probe issues.
- Make sure your Key Vault certificate includes
dev.yourdomain.comin the CN or SAN, and APIM has access via managed identity.
Refer to the Official Microsoft documentation for detailed guidance. Hope it helps!
If you have any other questions or still running into more issues, let me know in the "comments" and I would be happy to help you.
- Use
-
David R • 0 Reputation points
2025-05-27T20:31:26.2+00:00 Thanks for the reply.
What you describe is exactly what we did. However, small but important detail, is that the gateway CNAME must also be on *.azure-api.net when creating developer portal custom name, even if developer CNAME is already pointing to *.developer.azure-api.net, otherwise it just removes itself after saving. This is the initial problem.
The issue now is that the custom health probe for developer portal sees the wrong backend certificate.
The Common Name of the leaf certificate presented by the backend server does not match the Probe or Backend Setting hostname of the application gateway.
Clicking Troubleshoot we see it's pointing to *.azurewebsites.net:
We do specify the hostname in the Backend setting and use the custom probe as described in the documentation you linked.
We use a wildcard cert so it shouldn't be an issue on that end either.
The gateway returns the correct common name/cert on the backend, but not the developer portal. (We did have issues with gateway initially too and had to delete and recreate it).
I wasn't able to create the custom domain using the CLI. It returned this error:
(ResourceGroupNotFound) Resource group 'Contoso-Staging-AppPRO' could not be found.
Code: ResourceGroupNotFound
Message: Resource group 'Contoso-Staging-AppPRO' could not be found.
The resource group does indeed exist and the correct subscription was set-AzContext.
At this point it really feels like we did everything right and it's just not working.
Is there anyway we can hop on a call? It would speed up the troubleshooting immensely.
Thanks
-
David R • 0 Reputation points
2025-05-30T18:22:55.18+00:00 Just checking if somebody from Microsoft is still looking into this? We are hard stuck on this issue.
Thanks.
-
Gaurav Kumar • 790 Reputation points • Moderator
2025-06-05T17:56:41.6233333+00:00 Hi David R,
Apologies for the delayed response and thank you for your patience as we investigated your issue. Also, thank you for sharing the detailed explanation and diagnostic screenshot.
Root cause:
After analyzing your screenshot and Detailed explanation, I found the two key issues:
Developer Portal Custom Domain Disappears:
When configuring the custom domain, APIM attempts to validate the CNAME. If it doesn’t point to the default Developer Portal endpoint (
*.developer.azure-api.net), the validation silently fails and the domain is removed shortly after saving.TLS Mismatch in Health Probes:
The Application Gateway is probing
portal-apim-apppro-staging.<yourdomain>, but the backend (APIM) returns a certificate for*.azurewebsites.net, causing a hostname mismatch and probe failure.Solution:
Try the below workaround to fix the issue:
Set CNAME to Default APIM Endpoint Before Saving
Temporarily configure the DNS CNAME to point to the default Developer Portal endpoint:
<apim-name>.developer.azure-api.netOnly after APIM validates and saves the domain should you update the CNAME to point to your Application Gateway.
Use ARM Template or CLI for Domain Configuration
If the portal UI continues to remove the domain, try using the Azure CLI or ARM template.
az apim update --name <APIM_NAME> --resource-group <RsrGrpNme> --set hostnameConfigurations='[ { type: "DeveloperPortal", hostname: "portal-apim-apppro-staging.<yourdomain>", certificateSource: "KeyVault", keyVaultId: "<KeyVaultSecretUri>", negotiateClientCertificate: false, defaultSslBinding: true } ]'Double-check the resource group spelling/casing and ensure the correct subscription is set using
az account showConfigure Application Gateway Correctly
HTTP Settings: Override with specific hostname:
portal-apim-apppro-staging.<yourdomain>Custom Probe: Target
https://portal-apim-apppro-staging.<yourdomain>, accept 200–399 status codes, and override the host header with your custom domain.It ensures the hostname in the probe matches the certificate CN/SAN.
Certificate & Key Vault Access
Ensure the certificate includes the custom domain in its CN or SAN.
APIM’s managed identity must have:
Key Vault Readerrole,GetandListpermissions on secrets.Validate Certificate from Within VNet
Run from a VM in the same VNet:
curl -v https://portal-apim-apppro-staging.<yourdomain>Make sure the certificate presented matches your domain and not the default
*.azurewebsites.net.I hope this helps clarify and resolve the issue. Please feel free to ask if you need further assistance.
-
David R • 0 Reputation points
2025-06-06T13:53:53.25+00:00 Hi Gaurav,
I do not see any new information in your latest reply.
The solution proposed does not work like I mentioned on May 27th.
Sign in to comment