Moving on-premises infrastructure to cloud has seen a exponential growth in recent years. Along with migration, there are so many use cases which require teams to setup Azure Virtual machine for their functioning. If you have worked in the industry for quite sometime you would agree we can never be fully secure against the unfortunate issues.

Not being able to connect to a virtual machine is one of those events which could be a point of contention. Troubleshooting a virtual machine connectivity can sometimes be quite tricky since we don’t have complete control on the underlying hardware and restricted on the options available at the operating system level.

In this article I explain how you can troubleshoot you VM connectivity issue.

First, you should confirm if the VM is responsive and your calls are getting some response. Few available options are:

a.) If you have another virtual machine in the same vnet, try Ping or telnet on port 3389, 22 depending on the OS. You can also try tcping or invoke-webrequest if your environment has restricted ping or telnet.

b.) If step a doesn’t work, you need to ensure your have required exceptions in the network security group (NSG). Check for default Inbound port rules (“Allow VNet Inbound” and “Allow Load Balancer Inbound”). Make sure to also check that there are no matching blocking rules that are listed below a lower-priority rule.

c.) After ruling out the NSG as a potential cause, you can run a connectivity check on the source VM, and check the response.
WindowsCheck connectivity with Azure Network Watcher using PowerShell
LinuxCheck connectivity with Azure Network Watcher using Azure CLI 2.0

d.) Check whether the network adapter is in a failed state.