Because the ICMP protocol is not permitted through the Azure load balancer, you will notice that you are unable to ping an Azure VM from the internet, and from within the Azure VM, you are unable to ping internet locations.
Note that while this applies to network traffic going through the external IP (VIP) through configured endpoints, ICMP is not blocked when connecting through an Azure virtual network gateway or ExpressRoute. Also, ICMP will work between internal IPs of VMs in the same virtual network or in the same cloud service.
Also note that while an instance-level public IP lets you communicate directly to a specific VM instead of through the cloud service VIP that can be used for multiple VMs, ICMP is not permitted in that scenario either.
To test connectivity, we instead recommend that you do a port ping. While Ping.exe uses ICMP, other tools such as PsPing, Nmap, or Telnet allow you to test connectivity to a specific TCP port.
For example, trying to ping yahoo.com from within an Azure VM fails as expected with request timed out because ICMP is blocked at the Azure load balancer:
Pinging yahoo.com [188.8.131.52] with 32 bytes of data:Request timed out.Request timed out.Request timed out.Request timed out.
Ping statistics for 184.108.40.206: Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
But using the Sysinternals PsPing tool, which allows you to test connectivity to a specific TCP port, you can successfully test connectivity from within the Azure VM to port 80 on an internet site.
PsPing v2.01 - PsPing - ping, latency, bandwidth measurement utility Copyright (C) 2012-2014 Mark Russinovich Sysinternals - www.sysinternals.com
TCP connect to 220.127.116.11:80: 5 iterations (warmup 1) connecting test: Connecting to 18.104.22.168:80 (warmup): 53.25msConnecting to 22.214.171.124:80: 52.26ms Connecting to 126.96.36.199:80: 52.14ms Connecting to 188.8.131.52:80: 52.32ms Connecting to 184.108.40.206:80: 51.48ms
TCP connect statistics for 220.127.116.11:80: Sent = 4, Received = 4, Lost = 0 (0% loss), Minimum = 51.48ms, Maximum = 52.32ms, Average = 52.05ms
Note that one exception to this is that ICMP pings will work to bing.com because Azure and Bing are both Microsoft properties.
Pinging 18.104.22.168 with 32 bytes of data: 5 iterations (warmup 1) ping test:Reply from 22.214.171.124: 6.85msReply from 126.96.36.199: 2.47ms Reply from 188.8.131.52: 2.30ms Reply from 184.108.40.206: 2.95ms Reply from 220.127.116.11: 2.39ms
Ping statistics for 18.104.22.168: Sent = 4, Received = 4, Lost = 0 (0% loss), Minimum = 2.30ms, Maximum = 2.95ms, Average = 2.53ms
Testing from on-premises to the Azure VM shows the same behavior. The ICMP traffic is blocked by the Azure load balancer and the ping requests timeout. But if you instead do a port ping, they will succeed (assuming the VM is running, isn't blocking the port in the guest firewall, and the port has a configured endpoint for the VM).
To confirm which ports are opened to the VM with Azure endpoints, in the Azure management portal, go to Virtual Machines, select the VM, then select Endpoints.
Pinging CLJun21WS12R2A.cloudapp.net [22.214.171.124] with 32 bytes of data:Request timed out. Request timed out. Request timed out. Request timed out.
Ping statistics for 126.96.36.199: Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
TCP connect to 188.8.131.52:56972: 5 iterations (warmup 1) connecting test: Connecting to 184.108.40.206:56972 (warmup): 60.44msConnecting to 220.127.116.11:56972: 61.28msConnecting to 18.104.22.168:56972: 63.41ms Connecting to 22.214.171.124:56972: 63.69ms Connecting to 126.96.36.199:56972: 60.41ms
TCP connect statistics for 188.8.131.52:56972: Sent = 4, Received = 4, Lost = 0 (0% loss), Minimum = 60.41ms, Maximum = 63.69ms, Average = 62.20ms
TCP connect to 184.108.40.206:5986: 5 iterations (warmup 1) connecting test: Connecting to 220.127.116.11:5986 (warmup): 61.49msConnecting to 18.104.22.168:5986: 65.29ms Connecting to 22.214.171.124:5986: 67.08ms Connecting to 126.96.36.199:5986: 62.70ms Connecting to 188.8.131.52:5986: 60.99ms
TCP connect statistics for 184.108.40.206:5986: Sent = 4, Received = 4, Lost = 0 (0% loss), Minimum = 60.99ms, Maximum = 67.08ms, Average = 64.02ms