Azure Reserved Public IP Addresses
The past week I have been working on a customer's new SharePoint 2013 environment dedicated for testing a SharePoint app. The customer requested a flexible and quick set up, so we chose for an Azure based platform. We set up three virtual machines (VMs) (Domain Controller, SharePoint server and a SQL server) and put them in a cloud service, added the content database and published the site.
One very important requirement was to keep the costs as low as possible, so we got the request to shut down the environment after office hours and the weekends. This was quickly arranged with use of the automation service in Azure. We created 2 run books, one for starting the VMs and one for stopping the VMs.
The next day I went to the office and tried to logon the SharePoint site, no response…
After a little troubleshooting I noticed that the public IP address that I used for publishing the SharePoint site had changed in the cloud service. A quick search on the World Wide Web gave me the answer: When you shut down (deallocated) all your VMs in a cloud service, the public IP address is released. When you start up your environment, the cloud service gets a new public IP address.
I was not really planning on changing the DNS records every morning, so I started my search for the solution.
Multiple suggestions were found. For example you can always leave one VM on, shut down the VMs in Windows and not in Azure or change the method of shutting down servers through script. All those are valid options, however you will create extra costs that we didn’t want building these solutions or running VMs 24/7. Then I found an article about reserved public IP addresses (RPIP) in Azure, something Microsoft introduced the 12th of May 2014. Great, exactly what I was looking for, a simple solutions with very low costs.
However, using the RPIP with an existing environment was not something they described. All the topics I found suggested that you must delete the cloud service and VMs, set up the environment through PowerShell with the RPIP in place and then attach your hard drives.
This is something you can do, but I like to find an easier way for such tasks. So I started the process for requesting the RPIP and attaching it to my cloud service or VM.
First you log on to PowerShell with your Azure account, and verify you are working with the correct subscription. Then you request the RPIP with the following command:
New-AzureReservedIP –ReservedIPName “insert name” –Label “insert name” –Location “insert your VMS/cloud service location”
With the following command you can verify that the RPIP is created, and what the IP address is:
And now the fun part, Azure has a command for attaching the RPIP to an existing Azure Service, there is not much known about it, but it makes our lives so much easier. The command looks like this:
Set-AzureReservedIPAssociation –ReservedIPName “insert name specified in the first command” –ServiceName “insert your servicename”
After running this command you can logon the Azure management portal and navigate to your VMs dashboard, all the Public VIP addresses have changed to the RPIP. Now you can publish your sites to the internet without the fear of losing the IP address.