1 min read

How to get the public IP address of a virtual machine using the Azure CLI

With the Azure CLI, use the command az vm list-ip-addresses to get the public IP address of a virtual machine.

RESOURCE_GROUP=myResourceGroup
VIRTUAL_MACHINE_NAME=myVirtualMachine
az vm list-ip-addresses \
  --resource-group $RESOURCE_GROUP \
  --name $VIRTUAL_MACHINE_NAME \
  --query "[].virtualMachine.network.publicIpAddresses[0].ipAddress" \
  --output tsv

And the command output will be something like this:

172.172.100.100

For more details, click on the link below to access the official documentation

az vm