问题
Why there is a difference between the IP address reported by Azure Application Insights and standard Google Search (What is my IP)?
- IP returned by Azure App Insights: xx.xx.xx.0
- IP returned by Google Search: xx.xx.xx.242
回答1:
Application Insights uses IP to fetch geo location information such as country/region and city and then discards the last octet of the IP for the privacy reasons.
If geo location information extracted from IP is not enough for the scenarios you'd like to address and you still want/need to send unmasked IP, you'd need to submit it as a custom property on the telemetry item with Application Insights SDK. You can use Telemetry Initializer to do that.
public class CopyIPTelemetryInitializer : ITelemetryInitializer
{
public void Initialize(ITelemetry telemetry)
{
if (!string.IsNullOrEmpty(telemetry.Context.Location.Ip))
{
telemetry.Context.Properties["client-ip"] = telemetry.Context.Location.Ip;
}
}
}
来源:https://stackoverflow.com/questions/42429148/ip-address-mismatch-between-azure-application-insights-and-google-search