Reserve VMs IP on Azure

Posted 29 March 2016 12:00 AM by Benjamin Moles Segovia

Recently we had the need to change the public IP of some Azure VMs to be static instead of dynamic to prevent them from changing when the VM is shut down or deallocated. It was interesting to see that it is possible to reserve the same IP the VMs are currently using which prevent us from having to update references to those IPs. And also it is possible to do so without any downtime as the VM doesn't need to be restarted. PowerShell is the only way available at the time being to get this done.

How to do it

1. The steps to reserve the VM’s IP are as follows:

Step 1: Get the settings required by PowerShell to connect to the Azure subscription. 

Step 2: With your favourite browser, navigate to https://manage.windowsazure.com, log in and select the subscription where the target VM is. 

Step 3: Run the following PowerShell command which will download a file with the settings required by PowerShell to connect to the same subscription.          

Get-AzurePublishSettingsFile

Step 4: Save the previously downloaded file in a safe location.

Connect PowerShell to the target Azure subscription

2. Run the following two PowerShell statements after setting the path to the Publishing Settings file (downloaded in the previous step) and the Azure Subscription Name.

Import-AzurePublishSettingsFile "<Path to Publish Settings file>"
Select-AzureSubscription -SubscriptionName "<Subscription Name>"

3. [Optional] We can check the currently reserved IPs:

Get-AzureReservedIP

We can also save this information to a file for tracking purposes.

Get-AzureReservedIP >> "C:\ReservedIPs.old.details.txt"

4. Reserve the IP that is currently assigned to the VM:

Run the following command after setting the right values to its parameters.

New-AzureReservedIP –ReservedIPName <IP Name> –Location "<Region>" -ServiceName <Cloud Service Name>

ReservedIPName: Name to be used to identify the reserved IP.
Location: Name of the Azure Region where the VM is and where the IP will be reserved.
ServiceName: Name of the Azure Cloud Service associated to the VM.

5. [Optional] We can check again the currently reserved IPs where the new IP should be:

Get-AzureReservedIP

We can also save this information to a file for tracking purposes.

Get-AzureReservedIP >> "C:\ReservedIPs.new.details.txt"

How to double-check the VM has a reserved IP

The above procedure not only reserves the IP but also associates it to the VM. We can confirm it with the following steps:
Step 1: With your favourite browser navigate to the new Azure Management Portal https://portal.azure.com/
Step 2: Select the subscription where the target VM is.
Step 3: Go to “Virtual Machines (classic)”.
Step 4: Select (click on) the target VM which IP has just been reserved.
Step 5: On the Settings panel click on “IP addresses”.
Step 6: On the “IP addresses” panel we can check whether the IP is reserved and associated to the VM:

Additional information

https://azure.microsoft.com/en-gb/documentation/articles/virtual-networks-reserved-public-ip/

Share:

Add your comment

 
 

 

Archive

Tagcloud

Digital Transformation employee engagement staff satisfaction productivity Microsoft Teams Office 365 Yammer cms content management system agile GDPR Microsoft Graph collaboration Microsoft sharepoint 2016 upgrade migration SharePoint Online 2016 Tech Trends Digital Disruption Context marketing marketing SharePoint 2010 SharePoint 2013 TFS Git security kentico Analytics intranet jquery QA Quality Assurance testing digital workspace content management websites Sitecore sitecore marketplace sitecore module cloud Microsoft Cloud Storage digital strategy technical consulting sitecore modules Experience database Sitecore 7 Sitecore 8 support account management customer experience Data Storage windows azure cms integration front end front end development prototype Cloud Storage StorSimple Front-end Development Layout SharePoint 2013 colour palette UI design website design log viewer sitecore cms website Azure big data business-critical sharepoint accessibility android apple chrome clear people clearpeople debug emulator ios mobile testing opera resize adobe desktop flash ie10 internet explorer 10 metro windows 8 bcsp SharePoint Advanced System Reporter reporting framework ControlMode form control master page placeholder publishing console SharePoint 2007 SharePoint error search search results search values software testing testing scenario audit content information architecture retention schedules PowerShell QuickLaunch scripts SharePoint server 2010 business solutions metalogix replication replicator storagepoint stena technet UK Technet picture library slideshow web part RTM released to manufacturing caml caml query MOSS 2007 query infopath