从 Azure 逻辑应用获取客户端 IP 地址

Get client IP address from Azure Logic app

我有一个由 HTTP 请求触发的逻辑应用程序,我想在工作流中使用调用者的 IP 地址进行日志记录和管理。

我收到的 HTTP headers(门户显示)仅包括以下内容:

 "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"

是否有任何进一步的设置将“X-Forwarded-Host”添加到headers,或任何其他方式从逻辑应用程序获取调用方的外部IP。

谢谢!

逻辑应用程序本身不支持此功能,您可以在此处为user voice请求投票。

但是您可以将 HTTP 请求传递给 LogicApp 中的 Azure 函数并使用下面的逻辑

#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}");
}