1

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 10.0.0.12 as "Primary" but I would like to make the 10.0.0.4 "Primary" and remove the 10.0.0.12 to get back to the original configuration I had.

Is there a way to do this?

0

You can remove the name "10.0.0.4" 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 10.0.0.4.

$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 10.0.0.4 -Subnet $subnet -Primary -PublicIpAddress $publicIP
$nic | Set-AzureRmNetworkInterface

Then you can add a new IP configuration as the Private IP address 10.0.0.12 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.