Hi @Pradeep,
When an Azure App Service is placed behind Azure Front Door, the backend service often does not receive the actual client IP address. Instead, it sees the IP address of Azure Front Door, which belongs to Microsoft's IP range. This happens because Azure Front Door acts as a reverse proxy, forwarding client requests to the backend service. While the original client IP is visible in the Front Door logs, it does not appear directly in the App Service logs or application code unless explicitly extracted.
To resolve this issue, you should retrieve the client IP address from the X-Forwarded-For
HTTP header, which Azure Front Door includes in the request. This header contains a comma-separated list of IP addresses, with the first entry being the actual client IP. In an ASP.NET application, you can extract the IP as follows,
public string GetClientIp(HttpRequest request)
{
string clientIp = request.Headers["X-Forwarded-For"];
if (!string.IsNullOrEmpty(clientIp))
{
return clientIp.Split(',')[0]; // Extracts the first IP from the list
}
return request.HttpContext.Connection.RemoteIpAddress?.ToString();
}
How to get the client’s IP address on an Azure Web App developed in ASP.NET
https://stackoverflow.com/questions/64660328/how-to-get-the-ip-address-of-caller-from-azure-api-management-and-application-in
Let mi know if you have any further assistances.
Please accept the answer, so that others can get help from it.