question

RajeebSharma-1214 avatar image
0 Votes"
RajeebSharma-1214 asked ·

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

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-machinesazure-virtual-machines-networkingazure-virtual-machines-migration
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TravisCragg-MSFT avatar image
0 Votes"
TravisCragg-MSFT answered ·

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.




· 3 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,

i think that the answer is in the last paragraph - Do not use IP but DNS.

The question includes basic flow in design as it seems in first glance, and our "job" is not always to provide an answer to what someone ask but for what someone need (even if at the time he ask the question he does not know that this what he need). The questions many times are wrong since they already based on wrong assumptions. The main job of an architect is to ask "why" and get to the real source of what is needed.

0 Votes 0 ·

The IP Address of the Cloud Service and VM, both are same. The output of the above statement is nothing.


The question now is, can I create a new VM (ARM) and complete my testing and switch the Public IP to the Reserved IP? According to my understanding, the Reserved IP can only be assigned to the Cloud Service (so only to a Classic VM) and one can only create a new VM using the Reserved IP, not assign later. Correct me if I am wrong.


Please take note, I am not using the option 'Migrate to ARM' for the migration of Classic VM. I am creating a new VM (ARM) and need testing including customer testing/scanning..etc.


@pituach, Sorry if my question is wrong. I have 3 such Classic VMs, created in 2014. I cannot remember, if ARM was available then and why I did not consider using it. Besides, the devices using the IP Address do not support URLs. If there is no option but to use URL, then will close this thread.


Thanks. </p>


0 Votes 0 ·
pituach avatar image pituach RajeebSharma-1214 ·

Hi @RajeebSharma-1214,


I think that I was not clear :-)


Your question is perfectly clear and it is a very common requests. My message above was simply a general comment to clarify that I think that we should always prefer using DNS over IP. In most cases it is not a good idea to count on your IP Address while DNS is more reliable.


I search a bit online and I did not find any post which cover your request, so I wrote one. I will add the link as an answer to your question in few seconds 🙂


0 Votes 0 ·
pituach avatar image
0 Votes"
pituach answered ·

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


· 5 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @pituach How are you doing my friend ?


Can't you do this simply by releasing with Powershell, and copy / paste the shadow, so you just shutdown one at a time ?


0 Votes 0 ·

Hi,

Yes, you can do it using PowerShell. In general, Everything that we can do in the Portal we can do with PowerShell. Maybe I am missing some rare cases but I don't remember any situation that the portal supported something before there was an option to do it using code.

The steps are the same 3 steps if we are using Powershell. (1) Stop VM, (2) releasing the Static IP. (3) Associating the Static IP .

I am not sure what you mean by "copy / paste the shadow".

0 Votes 0 ·

Armand - @Sirlupinwatson,

I have an offer for you :-)

Write the procedure to do the task using PoiwerShell -> add it as comment to post or send it to me on Facebook -> I will give you the credit for the solution and the readers will have another option to solve their needs 😀

What say you?

0 Votes 0 ·

Hi @pituach


The old VM (Classic) does not use a Static IP. Its a Reserved IP Address, which uses Classic model. How does one use it to assign to new VM (ARM)? I think, it cannot be done, as per my understanding.


But read somewhere, one can convert a Reserved IP (Classic) to a Static IP, is that true? if so, how to do that and if it can, then can it be assigned to the new VM (ARM)?


Besides, creating a new Static IP and assign to Network Interface, does it mean, a new IP created with the desired Address? If not, how does it get assigned, to the old IP Address? I think, it will create Static IP, with a new (dynamic) Address, not the address which one wants.


I think, I need to stop both the VMs -> release the Reserved IP Address (Classic) -> use that to assign to the new VM (ARM). The problem is how to do the last one, considering its Classic to ARM.


Sorry, if my understanding is wrong.


0 Votes 0 ·

@RajeebSharma-1214 You can migrate a classic reserved IP Address to an ARM Public IP and then attach it to your new ARM VM. There will be a downtime associated with the migration. You can also test this via a proof of concept to get a better estimation of the downtime and the steps involved.


0 Votes 0 ·
pituach avatar image
0 Votes"
pituach answered ·

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.


· 3 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Just remember that step 1 I could not test and confirm (the link which explain hoe to migration the reserved IP to Static IP)

0 Votes 0 ·

Hi @pituach


Thanks for the confirmation.


There is no way to create a Classic VM anymore. I wanted to test myself, before posting this question here. Since I could not, I thought, someone may have encountered this before and hence asked it.


I only have 3 Production Classic VMs, on which I have to try these steps, and only on the day of migration and be prepared to visit the sites to change the IPs, if something goes wrong.


Noted. I will test it on one of them first and proceed to do the remaining 2 based on results of the first.


Thanks.


0 Votes 0 ·
pituach avatar image pituach RajeebSharma-1214 ·

Sound great @RajeebSharma-1214 👍

I am glad I could help a bit

I think you can close the thread (mark the answer) :-)

0 Votes 0 ·