Today someone asked my how to re-enable an Azure VM network adapter. Using an on-premise hypervisor like VMware you can use the console session to access and re-enable the virtual network adapter. In this blogpost I describe how to deal with this situation when it’s inside an Azure VM. Help is on the way!
You can use the Azure Portal or use Powershell to regain access to your virtual machine.
Resolve using the Azure Portal
Log on to the Azure portal and go to the virtual network adapter settings on the Virtual Machine pane :
Change the IP address to any other valid IP address in the same subnet. After changing Azure automatically re-enables the virtual network adapter. Better safe than sorry, reboot the virtual machine and change the IP address to the old value (when it needs to be static) and now you have access to the virtual machine again!
Resolve using Azure Powershell
Use these steps to use the command line. Go to shell.azure.com or open an Azure powershell environment.
Find the NIC details of the VM that we need to fix using the following command :
Get-AzureRmNetworkInterface -ResourceGroupName “My-ResourceGroup”
Notice the network interface name, IP address and allocation method you are using.
Now we need to assign a different IP address to the same nic from the same subnet.
Use the following Powershell commands :
$Nic = Get-AzureRmNetworkInterface -ResourceGroupName "My-ResourceGroup" -Name "my_AzureVM"
$Nic.IpConfigurations[0].PrivateIpAddress = "10.2.5.197"
$Nic.IpConfigurations[0].PrivateIpAllocationMethod = "Static"
$Nic.Tag = @{Name = "Name"; Value = "Value"}
Set-AzureRmNetworkInterface -NetworkInterface $Nic
Reboot your virtual machine and change IP address back to the old value. You are all set!