Azure API Management passthrough to backend service
Asked Answered
O

2

6

I would like to setup an Azure API Gateway that accepts requests for a backend service and simply passes the requests through to the backend with no modification. For example: (-> means it would get routed to)

https://dude.azure-api.net/foo -> https://realapi.mycompany.com/foo

https://dude.azure-api.net/bar -> https://realapi.mycompany.com/bar

etc

I want to use wild cards to set this up so that I don't have to specify every single endpoint in every single API.

This is very, very similar to Use Azure Api Management as a passthrough

however, I have a combination of GET's and POST's so that accepted solution won't work.

Can anyone tell me how to do this?

Outmost answered 23/8, 2018 at 4:23 Comment(0)
J
5

You will have to create wildcard operation per HTTP method. For sample above you could create two APIs, one with /foo suffix, and another with /bar. Both should have two operations - GET and POST - with "/*" as URI template.

Alternatively if you want complete passthrough - create single API with "/" suffix and two operations - GET and POST - both with "/*" URI template.

Jigaboo answered 23/8, 2018 at 21:33 Comment(2)
For various reasons, I can't create a wildcard operation for every HTTP method. So I tried the 2nd method but I keep getting a 500 internal server error. Still trying to work through that. I tried replacing the backend with a well known, public REST API, and it seemed to work fine (at least the GET calls did - I have no way to test POST on that API). So there must be something specific with my own API that is causing the 500 error. I am using Postman to test it out. If I put in the real URL, it works fine. Swap in the Azure URL, and I get the 500 error.Outmost
When you try to test things from Azure Portal, do you see any trace with response?Jigaboo
P
0

For complete pass-though, you just need to specify "/" as the API URL Suffix

Pudgy answered 27/8, 2018 at 17:31 Comment(2)
I tried this, but it doesn't work for me. I just get a 404 not found error. Let's say my backend URL is realapi.mycompany.com and it has a "GET foo" endpoint defined. My Azure URL is dude.azure-api.net . So calling dude.azure-api.net/foo should get routed to realapi.mycompany.com/foo but I just get the 404. If I don't define any operations in Azure, do I have to do something else to the API setup to make this work?Outmost
You have to define operation. Try creating api with empty API suffix and one operation with /* template and GET method.Jigaboo

© 2022 - 2024 — McMap. All rights reserved.