Q: How to get Azure VM external IP address ( if you not use PublicIP service ) ?

A:  If you’re not using ReservedIP service field PublicIP will be empty ( as soon as there’s no reserved IP ) for command Get-AzureVM. I using Swtich-AzureMode just in case to be sure that we’re in right Azure mode in powershell right now.

PS C:\> Switch-AzureMode -Name AzureServiceManagement
PS C:\> Get-AzureVM

ServiceName                             Name                                    Status
———–                             —-                                    ——
abokov-jelastic                         abokov-jelastic                         ReadyRole


PS C:\> Get-AzureVM -ServiceName "abokov-jelastic" | Select-object  Name, DNSName, *IP*

Name                    : abokov-jelastic
DNSName                 : http://abokov-jelastic.cloudapp.net/
IpAddress               : 10.0.0.4
PublicIPAddress         :
PublicIPName            :
PublicIPDomainNameLabel :
PublicIPFqdns           : {}
OperationDescription    : Get-AzureVM

 


You may see that this VM have DNS name, internal IP, but public IP is empty, nevertheless that there’s is an external IP address which is linked to that VM. To get external IP you may use command Get-AzureEndPoint which returns all information about all endpoints for that cloud service – in my case I have 7 open ports and to make this more readable I select only few fields from output.

PS C:\> Get-AzureVM -ServiceName "abokov-jelastic" | Get-AzureEndPoint | Select-Object Name, Port , *ip*

Name Port Vip VirtualIPName
—- —- — ————-
dns-TCP 53 23.99.218.74
dns-UDP 53 23.99.218.74
http 80 23.99.218.74
http4848 4848 23.99.218.74
https 443 23.99.218.74
https4949 4949 23.99.218.74
ssh 22 23.99.218.74

 

Leave a Reply