API Management 502 error

Danilo Kasparian 26 Reputation points
2022-09-14T14:10:13.327+00:00

I am getting 502 Bad Gateway errors when testing any API call from my APIM

Here my configuration:

1 - APIM is configured with a Custom Domain with a certificate in the keyvault. Default SSL and negotiate client is enabled
2 - APIM is in a SubNet
3 - There is a Private DNS zone binded with the VNET containing the APIM SubNet
4 - There is no NSG
5 - My API is inside the same VNET in another SubNet
6 - My API works if I call directly from the browser

I tried to run Echo API and I had the same 502 error, the trace doesn't work and there is nothing in the diagnostic showing a possible problem.

What can be missing? Could you help me?

I tried the documents in the ms portal 502 troubleshooting but it didn't work

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,446 questions
Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,762 questions
Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,213 questions
{count} votes

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 22,441 Reputation points Moderator
    2022-09-16T02:00:32.113+00:00

    Update for the community:
    APIM is deployed in VNET - Internal mode and integrated with Application Gateway as per docs: Integrate API Management in an internal virtual network with Application Gateway. The direct call to backend API works from browser but when testing it from the azure portal using Test option, it returned 502 error.

    @Danilo Kasparian restarted Application Gateway after following docs: https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-backend-health-troubleshooting and it resolved the issue.

    Application Gateway must be restarted after any modification to the backend server DNS entries to begin to use the new IP addresses. This operation can be completed via Azure PowerShell or Azure CLI.

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.