There is situation that access azure function http trigger behind a firewall, but we cannot use the ip to access http endpoint as in Microsoft documentation, anyone knows why? how is azure http trigger is designed? I want to call http trigger with an ip address, How can I do that
CodePudding user response:
Azure is using name-based virtual hosting which means multiple web apps (and functions) are hosted on the same pool of servers and share the same IP addresses. As a consequence, Azure needs an additional property to determine which function should be called when an HTTP request is sent to an IP address and this is achieved by setting the HTTP "Host" header.
To get the inbound IP of your function run the following in a terminal
nslookup <YourName>.azurewebsites.net
Assuming the IP address returned here is 20.51.3.70 you can then send an HTTP request to this IP but you have to specify the "Host" header like so:
curl -i -H "Host: <YourName>.azurewebsites.net" http://20.51.3.70/api/<FunctionName>?code=<APIKey>