I have a simple Azure Function in C# Script (.csx) that's basically a proxy (receiving requests and forwarding them, then sending back the response).
It works fine except now i started sending requests to an ngrok target. Everything inside the functions works fine, include my log messages.
Except that the application making the call to the function (my application but also Postman for testing) receives a 502 Bad Gateway message.
The odd thing is that these 502 failures do not show up in Application Insights Failures.
How can I investigate more?
C# Azure Function returning 502 Bad Gateway, but no error message in the Streaming Logs or Application Insights Failures.
Update 1: I actually found entries in the Application Insights that show the request was completed successfully 200. Even though that's not the case for postman which receives 502
Update 2: Since i have working request (consumer receives 200) and non-working requests (consumer receives 502). I've tried comparing the headers of the responses.
One difference is that working request have a "Request-Context: appId=cid-v1:59e26eaa-a962-4c9d-a2c1-2541b4ae2e15" <> non-working have "Request-Context: appId=" where appId is empty.
Another difference is that non-working request have a response header "Transfer-Encoding: chunked".
<body>
<div id="header">
<h1>Server Error</h1>
</div>
<div id="content">
<div class="content-container">
<fieldset>
<h2>502 - Web server received an invalid response while acting as a gateway or proxy server.</h2>
<h3>There is a problem with the page you are looking for, and it cannot be displayed. When the Web
server (while acting as a gateway or proxy) contacted the upstream content server, it received an
invalid response from the content server.</h3>
</fieldset>
</div>
</div>
</body>
</html>