Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get Private Ips of Azure Vm's

#!/bin/bash

echo "Enter the names of the resource groups separated by spaces: "
read -a resource_groups

# Loop through each resource group and retrieve information about its Azure VMs
for resource_group in "${resource_groups[@]}"; do
  echo "Getting information for resource group: $resource_group"
  vm_info=$(az vm list --resource-group $resource_group --query "[].{Name: name, ResourceGroup: resourceGroup, ID: id}" -o table)

  echo "Here is the information about the Azure VMs in resource group '$resource_group':"
  echo "$vm_info"
  echo ""
done

I need private ips of azure virtual machines but this bash script not fetching

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

use this:

az vm list -d --query "[].{ResourceGroup:resourceGroup, Name:name, PrivateIP:privateIps}" -o table

to filter by resource group:

az vm list -d --resource-group $resource_group --query "[].{ResourceGroup:resourceGroup, Name:name, PrivateIP:privateIps}" -o table
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading