Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get private IP of VMSS using CLI

I'm trying to automate few of our BAT script and for this our script need to know the private IP of each instances of VMSS(no public IP for instances).

Is there a way to query the private IP of all instances under a particular VMSS using azure cli. I tried few command of LB and VMSS but didn't find a solution yet.

az vmss show -g <rg> -n <vmss>
az vmss list-instances -g <rg> -n <vmss>
az vmss nic list-vm-nics -g <rg> --vmss-name <vmss> --ids <id>
az network lb address-pool list -g <rg> --lb-name <lb>
az vmss list-instance-connection-info -g <rg> -n <vmss>

Any help is highly appreciable and I'm not looking for powershell.

like image 899
lambodar Avatar asked Nov 21 '18 08:11

lambodar


People also ask

How do I find my private VM IP address?

Select ipconfig1 in the IP configurations page. Select Static in Assignment. Change the private IP address if you want a different one, and then select Save. If you change the private IP address, the VM associated with the network interface will be restarted to utilize the new IP address.


1 Answers

You can use the Azure CLI and bash command:

az vmss nic list -g groupName --vmss-name ScaleSetName | grep -w "privateIpAddress"

It can show all the private ips like this:

"privateIpAddress": "192.168.1.4",
"privateIpAddress": "192.168.1.5",
like image 185
Charles Xu Avatar answered Oct 05 '22 10:10

Charles Xu