Hassan Baig Hassan Baig - 2 years ago 118
Linux Question

How to reserve IP when provisioning Azure VM (resource manager)

I'm provisioning a new Azure VM (resource manager) via Ubuntu command line. I'm following the steps outlined here to do so: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-tutorial/

My question is: while provisioning a new VM, what do I do on the command line to ensure it has a static IP (reserved IP)?

The same thing can be accomplished using Azure PowerShell via
New-AzureReservedIP -ReservedIPName $reservedIP -Location $location

Answer Source

You need to define a public IP address as part of your Resource Groupm then assign it to the correct Virtual NIC (Network Interface Card).

A public IP Address resource type represents a DNS name on the public internet. It may be used to provide a DNS name to either a virtual IP address (VIP) hosted on an Azure Load Balancer or a public instance IP address (PIP) hosted directly on a VM.

With the Azure CLI, you need to write something like this:

azure network public-ip create -g MyResourceGroup -a Dynamic -l northeurope MyPublicIP

Then you would assign your IP to the Virtual NIC of the VM. Both the VM and the NIC are part of the same resource group:

azure network nic set -g MyResourceGroup -p MyPublicIP MyNicName

You can use "azure network nic list" to get the name of the NIC.

It also seems that currently only Dynamic Public IPs are supported for being used directly on VMs (in ARM mode). Right now, static IPs can only be assigned to Load Balancer configurations. Trying to use "-a Static" spits out an error when doing "azure network nic set":

Network interface xxx references public IP address yyy with AllocationMethod property set to Static. Currently this configuration is not supported. Network interfaces can use only dynamic public IPs.

I would also like to find out when this will be supported.

edit: here is a good Azure CLI reference. You can also use -h to get command usage help.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download