Missing Client IP Address in Azure App Service

Pradeep 20 Reputation points
2025-03-19T10:08:42+00:00

I have two Azure App Services configured under Azure Front Door. When a client accesses the app service, the request goes through Front Door and is routed to the app service. While I can see the client IP address in Front Door, the client IP is missing in the app service admin page, which only shows Microsoft IPs. I am using Azure App Service, Azure Front Door, and nopCommerce on Azure App Service.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,643 questions
0 comments No comments
{count} votes

Accepted answer
  1. Shree Hima Bindu Maganti 3,990 Reputation points Microsoft External Staff
    2025-03-19T12:31:01.74+00:00

    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();
    }
    

    Azure Front Door HTTP headers

    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.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.