Jayendran
Jayendran

Reputation: 10960

Is there a way to List all the VM's from the Application Security Group

As we know we can group the Vm's into a single App Security Group and use them as a Single Entity for the NSG rules.

I'm searching a way to find what are all the VM's thats associated to my security group.

From the azure CLI its showing the properties of App Security Group, but not the Association of VM's it does.

Is there a way to get/list all the VM's for a given Application Security Group ?

Upvotes: 2

Views: 2984

Answers (2)

Jayendran
Jayendran

Reputation: 10960

Ken provided the exact path to the solution. All I need to do is to to find the relevant queries(jmespath) in Azure CLI . I used the below query to get the desired solution for my use-case

az network nic list --query "[].[ipConfigurations[].applicationSecurityGroups[? contains(id,``<replace-your-asg-name>``)],virtualMachine]"

Ofcourse the above query needs some work as it will still show all VM list . May be it will give some lead to others to enhance it more precise for their needs.

Upvotes: 1

Ken W - Zero Networks
Ken W - Zero Networks

Reputation: 3814

You have to look at this from the NIC. If you do a az network nic list you can see the ASG's assigned to a NIC. You can look at this answer on how to list out the nic's associated with a VM.

azure cli list nic attached to VM

Upvotes: 1

Related Questions