01 Run account list command (Windows/macOS/Linux) using custom query filters to list the IDs of the subscriptions available in your Azure account:
az account list
--query '[*].id'
02 The command output should return the requested subscription identifiers (IDs):
[
"abcdabcd-1234-abcd-1234-abcdabcdabcd",
"abcd1234-abcd-1234-abcd-abcd1234abcd",
]
03 Run vmss list command (Windows/macOS/Linux) using custom query filters to list the name and the associated resource group of each virtual machine scale set provisioned in the selected Azure subscription:
az vmss list
--subscription abcdabcd-1234-abcd-1234-abcdabcdabcd
--output table
--query '[*].{name:name, resourceGroup:resourceGroup}'
04 The command output should return the requested virtual machine scale set identifiers:
Name ResourceGroup
--------------------- ------------------------------
cc-frontend-scale-set cloud-shell-storage-westeurope
cc-backend-scale-set cloud-shell-storage-westeurope
05 Run vmss list-instances command (Windows/macOS/Linux) using the name of the virtual machine scale set that you want to examine as identifier parameter, to list the IDs of the virtual machine (VM) instances running within the selected scale set:
az vmss list-instances
--name cc-frontend-scale-set
--resource-group cloud-shell-storage-westeurope
--query '[*].id'
06 The command output should return the requested instance identifiers (IDs):
If the
vmss list-instances command output returns an empty array, as shown in the example above, the selected Azure virtual machine scale set does not have any VM instances currently attached.
07 Run vmss show command (Windows/macOS/Linux) using the name of the virtual machine scale set that you want to examine as identifier parameter, to describe the ID of the load balancer backend pool associated with the selected VM scale set:
az vmss show
--name cc-frontend-scale-set
--resource-group cloud-shell-storage-westeurope
--query 'virtualMachineProfile.networkProfile.networkInterfaceConfigurations[*].ipConfigurations[*].loadBalancerBackendAddressPools[*].id | []'
08 The command output should return the requested backend pool identifier:
If the
vmss show command output returns an empty array, i.e. [], the selected Azure virtual machine scale set is not linked to an active load balancer.
09 If both conditions are met, i.e. there are no VM instances and load balancers associated with the scale set, the selected Microsoft Azure virtual machine scale set is considered empty and can be safely removed from your cloud account.
10 Repeat steps no. 5 – 9 for each Azure virtual machine scale set deployed in the selected subscription.
11 Repeat steps no. 3 – 10 for each subscription created in your Microsoft Azure cloud account.