How to change Azure Virtual Machine Public IP address without stopping the VM
How to change VM Public IP address without stopping the VM
To change the Public IP address of your VM, without stopping it, the following steps will help. Its a combination of CLI and PS scripts for a quick reference 🙂
- Login to your Azure tenant with PowerShell
- I hope, you already have a VM with a public IP address assigned. So, un-assign the public IP
$nic = Get-AzNetworkInterface -Name vmpub1930 -ResourceGroup manurg1 $nic.IpConfigurations.publicipaddress.id = $null Set-AzNetworkInterface -NetworkInterface $nic
- Create a New Public IP
az network nic ip-config update --name ipconfig1 --nic-name vmpub1930 --resource-group MANURG1 --public-ip-address myVMPublicIP
- Assign the new Public IP to the VM
az network nic ip-config update --name ipconfig1 --nic-name vmpub1930 --resource-group MANURG1 --public-ip-address myVMPublicIP