Create a Reserved IP for a Classic Azure VM

February 29th 2016 Azure PowerShell

Newly created classic virtual machines in Azure have dynamic public IP addresses. Although, Resource Manager is now the recommended deployment model, there are still image templates in the marketplace that requires classic deployment model. If you don't want the IP addresses of these virtual machines to change when they are stopped, you will need to reserve the IP. At the moment this can only be done using Azure PowerShell.

Installing Azure PowerShell

The recommended way to install the required PowerShell modules is from the PowerShell gallery. You should run the following commands with elevated administrator privileges:

Install-Module AzureRM
Install-Module Azure
Import-Module Azure

In my case the very first command failed, already:

Module AzureRM was not found in central repository

According to Get-PSRepository, the PowerShell gallery was correctly registered as the only repository, so that shouldn't happen. In the end, I resolved the issue by attempting to register the same repository once again with a different name:

Register-PSRepository -Name 'temp' -SourceLocation

The command failed because the same repository can't be registered twice:

PackageManagement\Register-PackageSource : The repository could not be registered because there exists a registered repository with Name 'PSGallery' and SourceLocation ''. To register another repo sitory with Name 'temp', please unregister the existing repository using the Unregister-PSRepository cmdlet.

But before that, it detected a missing or outdated NuGet provider:

PowerShellGet requires NuGet provider version '' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\Damir\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion -Force'. Do you want PowerShellGet to install and import the NuGet provider now?

Approving the installation of the updated NuGet provider, resolved the issue. The original Azure PowerShell installation script now worked without errors.

Adding a Reserved IP

Before running any other Azure PowerShell commands, you must first connect to your Azure account:


The command will open a dialog for you to login into Azure with your account. Now all the other commands will work as well.

To reserve an IP address for your virtual machine, you need to call the following command:

New-AzureReservedIP -ReservedIPName "name" -Location "location" -ServiceName "vm"

Make sure you replace all the arguments with appropriate values:

  • name is a name for the Reserved IP address that will help you identify it in the Azure Portal. Although you can't create a reservation in the portal, you can see it and delete it there.
  • location is the location where you create your VM (e.g. West US)
  • vm is the DNS name of your VM without the part, as you can see it listed in the portal.

The command will run for some time. Once it completes, you can confirm in the portal that it ran successfully. In the IP addresses settings for your VM, you will see the IP address assignment as Reserved.

Reserved IP address in Azure Portal

Notice, that the reserved IP will not be deleted automatically when you delete the virtual machine. Also, while the first 5 reserved IP addresses are free, you will still be charged for them if they are not in use. Therefore, don't forget to delete the reserved IP address, after you delete the VM you reserved it for.

Get notified when a new blog post is published (usually every Friday):

If you're looking for online one-on-one mentorship on a related topic, you can find me on Codementor.
If you need a team of experienced software engineers to help you with a project, contact us at Razum.
Creative Commons License