Normally, we uses cloud based VMs through SSH or RDP, so a network connection is necessary for connecting to the VM. But what if you accidentally disabled the NIC on your cloud VM? You may want to call Azure Support or find a previous snapshot for restoring VM. That's not necessary! Azure can help you restore your NIC by yourself in a few steps.

Experiment

I created a Windows Server 2019 VM on Azure, and disabled it's only NIC.

netsh interface set interface "Ethernet" disable

Boom, I lost my server.

Because the NIC is disconnected, so neither can I RDP into the VM nor using WinRM over PowerShell. It is just gone.

Restoring NIC using Serial Console

Actually, there's still a chance in situations like this. In Azure Portal, go to the VM's management screen, and click the "Serial console" menu. 

"The Serial Console in the Azure portal provides access to a text-based console for virtual machines (VMs) and virtual machine scale set instances running either Linux or Windows. This serial connection connects to the ttyS0 or COM1 serial port of the VM or virtual machine scale set instance, providing access independent of the network or operating system state. " 

Now, a console screen is shown on the Azure Portal, this is the Serial Console itself, not from the VM, we will use it to go to VM's cmd shell. Enter cmd.

Now, a new channel named Cmd0001 is created.

Enter ch -si 1 to go to that channel.

Press Enter to continue.

Login to your VM's with your VM's credential.

Now, this is the actual cmd running on your VM. We can now enable the NIC.

netsh interface set interface "Ethernet" enable

I am now able to RDP into the VM again!

What About Linux

Well, Microsoft Loves Linux:

Reference: https://channel9.msdn.com/Shows/Azure-Friday/Troubleshoot-and-diagnose-Azure-Virtual-Machines-with-Serial-Console