I have an Azure VM with multiple static IP addresses. I had to delete and recreate the VM a couple times due to lost connectivity, and ended up with this IP Configuration:

enter image description here

It automatically assigned as "Primary" but I would like to make the "Primary" and remove the to get back to the original configuration I had.

Is there a way to do this?


You can remove the name "" Secondary type IP first, if not, you will have IP conflict when you add the same IP to another IP configuration. Then run the following PowerShell script to set the private IP address of the primary IP configuration ipconfig1 to

$vnet = Get-AzureRmVirtualNetwork -Name myvnet -ResourceGroupName myrg
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name mysubnet -VirtualNetwork $vnet
$publicIP = Get-AzureRmPublicIpAddress -name publicIpName -ResourceGroupName myrg
$publicIp.PublicIpAllocationMethod = "Static"
$nic = Get-AzureRmNetworkInterface -Name nic1 -ResourceGroupName myrg  
$nic | Set-AzureRmNetworkInterfaceIpConfig -Name ipconfig1 -PrivateIpAddress -Subnet $subnet -Primary -PublicIpAddress $publicIP
$nic | Set-AzureRmNetworkInterface

Then you can add a new IP configuration as the Private IP address back.

Ref: Set-AzureRmNetworkInterfaceIpConfig

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.