Azure CLI - Get VM IP Address List

event 2021-12-22 visibility 4,831 comment 0 insights
more_vert
insights Stats
Raymond Raymond Code Snippets & Tips

Code snippets and tips for various programming languages/frameworks. All code examples are under MIT or Apache 2.0 license unless specified otherwise. 

Azure CLI can be used to easily retrieve VM IP address list. This article shows you how about retrieve a single VM's IP address list or all VMs' IP addresses in a resource group or subscription. For a list of VMs, we will use JMESPath to query it. 

Code snippets

Retrieve a single VM's IP addresses

az vm list-ip-addresses -g resourceGroupName -n vmName

Retrieve all VMs' IP addresses in a resource group 

az vm list-ip-addresses --ids $(az vm list -g resourceGroupName --query "[].id" -o tsv)

Retrieve all VMs' IP addresses in a subscription

az vm list-ip-addresses --ids $(az vm list --subscription subscriptionIDOrName --query "[].id" -o tsv)

References

az vm

More from Kontext
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts