In my previous blog, we learnt that a Virtual IP (VIP) get 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 IP per subscription and you can contact to Microsoft if you need more reserved IP.
Reserved IP associate a static IP to cloud service and removes the limitation of VIP when VM restarts and VIP gets changed.
There are 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 login to our Azure account as we did in our previous blogs using azure cmdlet Get-AzureAccount.
After we login to Azure account we will write cmdlet to create a new reserved IP.
New-AzureReservedIP –ReservedName “KKReservedIP01” –Label “KKReservedLabel01” –Location “South India”
Here “KKReservedIP01” is the name of reserved VIP.
“KKReservedLabel01” is the name of label.
“South India” is the location where we want to reserved VIP so Azure will provide a reserved VIP based on the region we select.
Now we have created a reserved VIP we will check which reserved VIP address is allocated by Azure based on the region.
So here we can see from the details the VIP address issued by Azure based on location.
Also, its showing that new reserved ip (184.108.40.206) 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 Azure portal and select the new reserved ip name from list.
So we have created a virtual machine with reserved IP.
Let’s check again the values of labels from cmdlet Get-AzureReservedIP.
Here we can see that 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 also showing 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
Here, we can see that the VIP value is not changed and 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.
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.