How to reserve Public IP address of existing VM and apply to new VM

Rajeeb Sharma 1 Reputation point
2020-06-09T05:46:15.353+00:00

Hi

How do I reserve the Dynamic Public IP address of an existing Virtual Machine (Classic) and apply to a new Virtual Machine (ARM) later?

Below is the scenario, for which it is required

  1. The existing Public IP Address of the VM (Classic) is used in many devices to connect to the VM
  2. We have to migrate the application to a new VM (ARM), with 0/min downtime
  3. Cannot visit each device to change the IP Address to a new one
  4. Can we setup a new VM (ARM) using static Public IP (actually not sure if Static/Dynamic will make any difference though) -> complete all the testing -> (Reserve the IP Address of the old VM??) - > Shutdown the old VM (Classic) -> Change the Public IP address of the new VM (ARM)?

I think, the Reserved IP address works only with Cloud Services (or VIP), because the -SeviceName does not recognize anything except a cloud service, if you use VM Name, it shows resource not found.

Is there any other option to retain the same IP Address for the new VM (ARM), with no downtime?

Even if 'Migrate to ARM' option can keep the same IP Address, but we are not sure, if we can migrate to ARM with all the changes, we would like to do, like put in a different resource group, virtual network, different VM size, different disk..etc.

Thanks for any help.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,086 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. TravisCragg-MSFT 5,676 Reputation points Microsoft Employee
    2020-06-12T09:08:47.837+00:00

    There are multiple parts to this question, and lets start with the migration. Only Reserved IP Addresses are available for migration from classic to ARM. You can take an existing cloud service IP Address and make it reserved using Azure PowerShell.

    I assume that you have gotten this far, as you speak about the limit with Cloud Services.

    There are 2 types of Public IP Addresses for Classic VMs, Cloud Service Public IPs and Instance Level Public IPs. Instance Level Public IPs are not able to be migrated to ARM.

    The easiest way to tell which type of Public IP you have is to check the public IP of the cloud service the VM is in, or use the following PowerShell Script:

    #Get the associated iInstance Level Public IP Name for a virtual machine      
    Get-AzureVM -ServiceName "MyCloudservice" -Name "VMname" | Get-AzurePublicIP  
    

    This will output an Instance Level Public IP if attached to the VM. If this does not output your IP Address, it means that the public IP is on a Cloud Service, and can be converted to a reserved IP Address.

    If you can convert the IP to a Reserved IP Address, you can migrate the VM and IP Address to ARM, then switch the Public IPs. There will be a small downtime associated with the switch, typically no more than a minute.

    If the IP Address is an Instance Level Public IP, there is no way to migrate the IP Address. In the future, it is highly suggested to use a DNS name when entering addresses into applications, that way IP swaps are a simple switch on a DNS entry instead of having to change code on several different applications.


  2. Ronen Ariely 15,096 Reputation points
    2020-06-14T00:29:06.94+00:00

    Hi @RajeebSharma-1214,

    The solution to your need is very simple.

    The short procedure is this:

    1) Stop both VM (the old one which uses the Static IP now, and the new one which you want to migrate the IP to)

    2) In your old VM where the Static IP is associated, Dissociate the Static IP Address.

    3) Go to the IP and associate it to the Network Interface of the new Virtual Machine

    If you already have a Network Interface in the new machine, which had no IP or Load Balance associate to it, then the entire procedure can be done in the Azure Portal with less clicks then the number of your fingers :-)

    The full tutorial from theory to different scenarios, can be found in the following post:

    https://ariely.info/Blog/tabid/83/EntryId/262/Introduction-to-network-Azure-public-IP-and-advanced-practical-scenarios-of-using-static-public-IP.aspx

    More information

    How to reserve Public IP address of existing VM

    If the Public IP is static then the IP Address is reserve regardless of the Virtual Machine. You can Dissociate the Static Public IP and re-associate it to any network interface which fit the limitation (more in the lined post)

    apply to new VM

    As mentioned, the Public IP is a separate entity (azure service) and all you need is to associate it to the Network Interface which is associate to the new Virtual Machine. The IP Address will stay the same if this is Static Public IP Entity since the address is associate to the IP service and not to the VM


  3. Ronen Ariely 15,096 Reputation points
    2020-06-15T21:59:48.167+00:00

    Hi,

    As much as I understand from you: You have an old VM which you created in the old portal <https://manage.windowsazure.com/> (This is what we call a classic VM). The Classic VM you have uses a classic public IP which is a Reserved IP. You want to migrate the Classic Reserved IP to an ARM Static Publish IP.

    Note! Unfortunately, I need to reproduce a scenario in order to test it and solve/confirm an issue, but the old portal redirect to the new portal for long time ago if you don’t have a classic service. The migration of the services to the "new" portal stared in 2015. As time pass it is getting much harder to find information about the Azure Classic and migration to the new ARM portal. At this time I do not have any account which have classic service (I might have option to work with the old classic in about 2 weeks since I have a call for support a client which might have it - don;t count on it). Therefore, I cannot reproduce a classic VM and/or Classic reserve IP at this time. This means that I can only provide old information without tests or confirm that it is accurate. I really do not want you to count on my memory from 2015 :-)

    Anything that you do, is on your own responsibility. I think a better approach is to start from scretch and instead of migrating the Azure Services you can migrate your services (meaning create new VM and new STatic IP and configure your App there.

    But read somewhere, one can convert a Reserved IP (Classic) to a Static IP, is that true? if so, how to do that

    Yes it is supported as @TravisCragg-MSFT (Travis Cragg) mentioned already. You can migrate the classic Reserved IP to a Static Public IP.

    I found this step-by-step explanation: (✅1️⃣)

    https://stackoverflow.com/questions/45190296/how-can-i-migrate-an-azure-reserved-ip-classic-to-an-azure-public-ip-arm

    if so, ... then can it be assigned to the new VM (ARM)?

    Yes. After you finish to migrate the IP, then this part I covered in my blog (✅2️⃣). This step was tested and is done many times. Once you have Azure Static IP (after previous step) , then check my post. You have "Associate Existing Static IP to a new Virtual Machine" and you have "Associate Existing Static IP to Existing Virtual Machine"

    Besides, creating a new Static IP and assign to Network Interface, does it mean, a new IP created with the desired Address?

    No. New Static IP will get new address unless you migrate the old reserved IP. Check the link above to the step-by-step toturial.