简体   繁体   中英

How to find outbound IP of azure function app runtime?

I am trying to identify the IP from which my azure function app is trying to connect the other app. I know the IP can belong to list of outbound IPs. I need to know the specific one and that too when my function app code is running.

While finding solution I got this code as answer

Dns.GetHostEntry(Dns.GetHostName()).AddressList.Where(o => o.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).First().ToString()

But sadly, it's showing IP of some diffrent machine which doesn't even show up in outbound IPs.

Is there any specific code which can help me find which IP the current instance of function app belongs to?

From here :

Each function app has a set of available outbound IP addresses. Any outbound connection from a function, such as to a back-end database, uses one of the available outbound IP addresses as the origin IP address. You can't know beforehand which IP address a given connection will use. For this reason, your back-end service must open its firewall to all of the function app's outbound IP addresses.

As I said in the comment: If you want to know those IP from within the Functions code (although I don't know why you would need that), you would need to use the Azure Management SDK to do something similar than what the powershell command in the link above does.

I've figured this thing out. The outbound ip and the ip on which azure function is running are different. They say azure function is a server less application. Which truly means there is no specific machine on which the app may run. So everytime when the function app runs it picks up a random machine from the pool of available machines to it. However the outbound ip is the ip which it uses to communicate the external environment. And it won't be available at the time when the function app is running. It's independent of the machine on which the function is running but it belongs to set of outbound IP address from function app property.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM