In 2024, Azure Front Door does not appear to provide the client IP address as perhaps it did in the 2021 answer.
To get it, use a Front Door Rule Set.
You may or may not need to change your code, depending on which Request header value your existing code relies on. In my code migration to Azure, the code was previously depending on CloudFlare's "CF-Connecting-IP" header. That meant for me now that I could set up a Front Door rule to add that header to incoming requests.
You can't change or overwrite some Azure headers, so you may even end up creating a new one in a rule set e.g. "RuleSet-Client-IP".
These instructions work for Azure Front Door Premium.
- Navigate to your Front Door resource
- Under Settings, click on Rule sets
- Click Add rule
- Make it similar to the first image below, with the header value being
{client_ip}
.
- Save
After creating the new Rule Set, you need to connect it to at least one Front Door Route. This is done from the list of Rule Sets, clicking the three-dots menu at the end of the ClientIpRules line, and choosing Associate a route.
If your code needs changing to pick up the header name that you used, then change your code.
X-Forwarded-For
header. – Corpus