Azure-Functions
Azure-Functions copied to clipboard
Introduce a method to retrieve client IP address easily
Getting the client IP address is not trivial. It'd be great if you could expose functionality to retrieve IP address information easily. I frequently log this info for every API request. I'm not sure if reading X-Forwarded-For
will always be supported.
https://stackoverflow.com/questions/37582553/how-to-get-client-ip-address-in-azure-functions-c
Looking at the answers, it's clear that IP address retrieval is pretty messy.
X-Forwarded-For will only work if the client sets that header... Node.Js server, express, etc. out of the box provide a way to retrieve the client IP. It should be made available in the context object.
For any future readers, I found out that Azure will always set the "X-Forwarded-For" header. It may not be available in local debugging, but on Azure it will be.
Please let us know if this is yet to be triaged, so that I can route this issue to concerned team.
When I updated to the lastest SDK the X-Forwarded-For header is no longer present on "Bring your own functions" for a static web app Also see: https://github.com/Azure/Azure-Functions/issues/2237#issuecomment-1930348682 Not being able to get the client IP address is pretty fundamental and means we can't move to dotnet 8