sz.krisz
sz.krisz

Reputation: 53

Get client IP address from Azure Logic app

I have a Logic app triggered by HTTP request and I would like to use the caller's IP address for logging and administration purposes in the workflow.

My HTTP headers received (shown by portal) only includes the following:

 "Host": "prod-101.westeurope.logic.azure.com",
    "User-Agent": "Mozilla/5.0,(Windows NT 6.3; Microsoft Windows 6.3.9600; hu-HU),PowerShell/7.1.3",
    "Content-Length": "350",
    "Content-Type": "application/json"

Is there any further setting to add "X-Forwarded-Host" to headers, or any other way to obtain the caller's external IP from the logic app.

Thanks!

Upvotes: 3

Views: 2211

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222692

This is not supported natively by logic App, you can upvote the user voice request here.

however you could pass the HTTP request to an Azure function within the LogicApp and use the logic below

#r "System.Web"

using System.Net;
using System.Web;

public static HttpResponseMessage Run(HttpRequestMessage req, TraceWriter log)
{
    string clientIP = ((HttpContextWrapper)req.Properties["MS_HttpContext"]).Request.UserHostAddress;
    return req.CreateResponse(HttpStatusCode.OK, $"The client IP is {clientIP}");
}

Upvotes: 1

Related Questions