如何从 Azure API Management and Application Insights 获取调用者的 IP 地址

How to get the IP address of caller from Azure API Management and Application Insights

我们的基础架构包含一个 Azure HTTP triggers,它通过 Azure API Management Service 接收客户端 REST 调用。

我们始终使用 Application Insights 进行记录。但是,client_IP 字段总是显示为 0.0.0.0。以下示例是来自 Application InsightsRequests table 的屏幕截图,已在 clould_RoleName 上过滤,以显示已被 API Management 捕获的请求。

我们缺少什么?

谢谢,

默认情况下临时收集 IP 地址,但不会存储在 Application Insights 中。详情可参考this article

要存储真实 IP 地址,您可以轻松地按照 this documents 在您的应用程序洞察资源 -> arm 模板中添加 key/value 对 "DisableIpMasking": "true"