Hello @kimjaeho
You can change Azure VM IP address from Azure Portal
- Create new Public IP resource in Azure Portal
- Select VM resource in Azure Portal
- Select Networking in Settings in your VM resource.
- In Networking, select the Network interface of the VM. The name of the NIC will be prefixed with the name of the VM and end with a random number.
- In Settings of the network interface, select IP configurations.
- Select ipconfig1 in IP configurations.
- Select new Public IP address created in step 1 of ipconfig1. and click Save
You can create Azure Automation Account and add below script to create new Public IP and associate it with the VM:
Example:
$ip = @{
Name = '<PublicIPName>'
ResourceGroupName = '<ResourceGroupName>'
Location = '<Location>'
Sku = 'Standard'
AllocationMethod = 'Static'
IpAddressVersion = 'IPv4'
Zone = 1,2,3
}
$newPublicIp = New-AzPublicIpAddress @ip
$vnet = Get-AzVirtualNetwork -Name <VirtualNetworkName> -ResourceGroupName <ResourceGroupName>
$subnet = Get-AzVirtualNetworkSubnetConfig -Name <VMSubnetName> -VirtualNetwork $vnet
$nic = Get-AzNetworkInterface -<VMNicName> -ResourceGroupName <ResourceGroupName>
$nic | Set-AzNetworkInterfaceIpConfig -Name ipconfigName -PublicIPAddress $newPublicIp -Subnet $subnet
$nic | Set-AzNetworkInterface