Reputation: 11
I am writing an Azure Function to ping a particular host to check response times using the System.Net.NetworkInformation.Ping class. I get a generic exception when calling Ping.Send, however this works fine locally.
Are there restrictions on network calls made outbound from Azure Functions?
The exception I get is simply:
Could not ping: An exception occurred during a Ping request.
at System.Net.NetworkInformation.Ping.Send(IPAddress address, Int32 timeout, Byte[] buffer, PingOptions options) at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options
Upvotes: 0
Views: 2317
Reputation: 9749
As ICMP protocol is not permitted through the Azure, you will not be able to ping an Azure VM from the internet, and from within the Azure VM, you are unable to ping internet locations.
To test connectivity, it is recommended to do a port ping. While Ping.exe uses ICMP, other tools such as PsPing, Nmap, or Telnet which allows you to test connectivity to a specific TCP port.
It is nicely explained in this post - https://blogs.msdn.microsoft.com/mast/2014/06/22/use-port-pings-instead-of-icmp-to-test-azure-vm-connectivity/
Upvotes: 2