Unable to access api exposed over VM through azure apim

Sumit Bharti 41 Reputation points
2022-04-08T21:19:05.413+00:00

We have an application running on azure virtual machine that doesn't have a public ip address.
We connect to VMs and other services on azure using existing VPN connection as established by the admin.

That application on the virtual machine exposes the back-end functionalities using REST API.
Testing the same using curl or api testing tool like Postman is successful as shown in below image:
191482-direct-api-call.png

Note above image is testing the api exposed from Virtual machine application directly.

Now, we want to expose the api through azure apim. We have done the configuration as shown in image below:
191463-apim-setup.png

If we test it in apim with same parameters that worked when we tested api directly show this:
191379-apim-testing.png

It shows testing successful with 200 response code. However, we dont get the actual response like "user has successfully logged in". Even if we pass wrong parameters that should not be successful, it still shows successful with 200 response code.
We tested using curl command and also postman and got 200 response code:
191438-apim-wrong-response.png

It doesn't matter what parameters we pass, it gives 200 response code. Not sure what we are missing, can someone please suggest?
I am attaching a document which shows the complete trace output.
191409-apim-trace.pdf

Thanks in advance

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

Accepted answer
  1. Takahito Iwasa 4,851 Reputation points MVP Volunteer Moderator
    2022-04-09T23:08:46.95+00:00

    Hi, @Sumit Bharti

    I think you need to connect to VNET in External Mode in your scenario. The following will be helpful, but is it set like this?
    https://learn.microsoft.com/en-us/azure/api-management/api-management-using-with-vnet?tabs=stv2

    Second, I couldn't see the operation settings from your settings.
    Can you see the access log of the origin (backend) server when you submit the request?

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Sumit Bharti 41 Reputation points
    2022-04-12T21:35:07.183+00:00

    We allowed traffic from the APIM subnet's IP Address range to the NSG rules attached the subnet of the virtual machine.
    This fixed the issue.

    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.