How To Create A Virtual Machine (VM) With Reserved Public IP (VIP)

In my previous article, we learned that a Virtual IP (VIP) gets lost or changed when we stop or deallocate the virtual machine (VM). So, to overcome this, we can assign a reserved IP so that whenever we restart the virtual machine, we would get the same IP.

Microsoft Azure allows default 20 reserved IPs per subscription and you can contact Microsoft if you need more reserved IPs.

Reserved IP associates a static IP to cloud service and removes the limitation of VIP when VM restarts and VIP gets changed.

There are a few limitations with Reserved IP,

  • Existing VIP cannot be converted into a reserved IP.
  • To get a static IP VMs must be created with reserved VIP first.

So, let us create a VM with reserved IP today using Azure Portal and PowerShell.

We will log in to our Azure account as we did in our previous blogs using Azure cmdlet Get-AzureAccount.

After we log in to the Azure account, we will write the cmdlet to create a new reserved IP.

New-AzureReservedIP –ReservedName “KKReservedIP01” –Label “KKReservedLabel01” –Location “South India”

Azure

 

Here, “KKReservedIP01” is the name of reserved VIP. “KKReservedLabel01” is the name of the label.

“South India” is the location where we want to reserve the VIP so Azure will provide a reserved VIP based on the region we select.

Now, we have created a reserved VIP.  Let us check which reserved VIP address is allocated by Azure based on the region.

Get-AzureReservedIP

Azure

 

So here, we can see from the details the VIP address issued by Azure based on the location. Also, it's showing that new reserved IP (52.172.43.213) is currently not in use and showing as False in InUse label.

Now, we will assign this reserved IP to a virtual machine.

We will create a new virtual machine from the Azure portal and select the new reserved IP name from the list.

Azure

 

So, we have created a virtual machine with a reserved IP. Let’s check again the values of labels from cmdlet Get-AzureReservedIP.

Azure

 

Here, we can see that the value of InUse label has changed to True which means that this reserved IP is currently in use now as we have assigned this VIP to our new virtual machine.

It is also showing the values for ServiceName, DeploymentName which were blank previously. Now, let’s restart the virtual machine and check whether VIP value gets changed or not.

To check the VIP values, we write the cmdlet Get-AzureVM –ServiceName kkvm02909 | Get-AzureEndpoint

Press Enter.

Azure

 

Here, we can see that the VIP value is not changed and is same as our reserved VIP.

We can also check the value of VIP from Azure Portal. For it, just click on the virtual machine name and select overview section or IP address section.

Azure

 

So, this is how we can reserve the VIP for a virtual machine if we don’t want to get its value changed every time we restart the virtual machine.


Similar Articles