Powershell Function with HTTP Trigger - How to get HttpContext RRS feed

  • Question

  • Hi guys,

    I have a c# Azure function with an Http trigger, in which I'm extracting the caller's IP address using;

    string clientIp = ((HttpContextWrapper)req.Properties["MS_HttpContext"]).Request.UserHostAddress;

    I'm using this IP address to manipulate an azure DNS Zone. However, this manipulation can only be performed via Powershell or CLI - NOT via REST.

    So what I'm after is a way to do the same thing in an HTTP triggered Powershell Azure function, but I'm not finding how to do it. I can get the actual request body and the headers, but not the IP address

    Anyone done something similar?

    Thursday, July 13, 2017 8:33 AM

All replies

  • One alternative to UserHostAddress is the 'x-Forwarded-For' header, which should be available in powershell as something like $req_headers_x-forwarded-for.
    Thursday, July 13, 2017 6:10 PM