How To Get Azure VM IP Addresses Using PowerShell

Curious as to what IPs are used by your Azure VMs?  This may seem a simple question, but it was not until last year that Azure allowed you to set static IPs on VMs.  Prior to this it was a first come first served basis.  The net result was that you powered VMs on in a set order to preserve the IP assignment scheme that you wanted.

The first usable IP address on the Azure VM subnet is the .4 address.  This is why I would power my DCs on first so that they would get .4 and .5 respectively and  Azure virtual network was configured so that .4 and .5 were the assigned DNS servers.

Azure PowerShell offers a nice easy way to see the IP information.  Download and connection details are available here with documentation.

Update 15-11-2016 If you want to obtain IP information when the VM is on Azure Resource Manager, please see this post.

Obtaining Azure VM IP Address Information

Connect into your subscription using Azure PowerShell, and once you have selected the relevant subscription issue the following command:

Get-AzureVM  -ServiceName TailspinToysCanada  | Select-Object Name, *IP* | Format-Table –AutoSize

Get Azure VM IP Addresses Using PowerShell

Note that in this case the Cloud Service is called TailspintoysCanada.  This is what is specified in the ServiceName parameter above.

You might be wondering why you only see IPs for two of the VMs.  Why is that?

Let’s add the InstanceStatus column in to the output.

Get-AzureVM  -ServiceName TailspinToysCanada  | Select-Object Name, InstanceStatus, *IP* | Format-Table –AutoSize

Get Azure VM IP Addresses Using PowerShell

Note that the red box highlights the current status of the VMs in this Azure Cloud Service.

Only two VMs are in a running state, the others are not.  This is why we only see the two IPs being reported.



Rhoderick Milne [MSFT]

Leave a Reply

Your email address will not be published. Required fields are marked *