No Internet access from Azure Windows VM that has multiple IP addresses

Applies to: Virtual Machine running Windows


In Microsoft Azure, you set multiple IP addresses in the network interface of an Azure Windows virtual machine. After you make the settings, the virtual machine cannot connect to the Internet or to Azure services, such as Azure Backup. 


This issue occurs because Windows selects the lowest numerical IP address as the primary IP address regardless of the address settings in the Azure portal.

For example, in the Azure portal settings for a Windows virtual machine, you set as the primary IP address and as the secondary IP address. In this situation, Windows selects as primary IP address.

This behavior blocks connectivity because only the IP address that is set as primary in the Azure portal is allowed to connect to the Internet and Azure services. 


To resolve the issue, run the following Windows PowerShell commands to change the primary IP address of the Windows virtual machine:

$primaryIP = "<Primary IP address that you set in Azure portal>"$netInterface = "<NIC name>"[array]$IPs = Get-NetIPAddress -InterfaceAlias $netInterface | Where-Object {$_.AddressFamily -eq "IPv4" -and $_.IPAddress -ne $primaryIP}Set-NetIPAddress -IPAddress $primaryIP -InterfaceAlias $netInterface -SkipAsSource $falseSet-NetIPAddress -IPAddress $IPs.IPAddress -InterfaceAlias $netInterface -SkipAsSource $true