GOAL: I want to list all VMs in our park with the relative number of cores.
In order to do so I found this query :
Resources
| where type=~ 'microsoft.compute/virtualmachines'
| project subscriptionId, name, location, resourceGroup, Capacity = toint(sku.capacity), Tier = sku.name
| order by Capacity desc
PROBLEM: the query return the column Capacity but they are all null
(Also solution in PowerShell will be accepted if they allow export to CSV)
I tried to reproduce the same in my environment.
Tried with the following query:
But not able to get number of cores .
As i do not have them enabled in my portal to display in Json of my Virtual machine template too.
As i also Tried with
properties.hardwareProfile.vmSizeProperties
Graph query:
Everything like hardware profile is resulting in output except vm size properties are empty which includes number of cores property for vmsize properties where it has to have number of cores.
Try Initially check the properties and then call the number of cores for each VM. Below command gives VM size particularly.
Command:
Command:
$MyVmZizeProperties = Get-AzureRmVMSize -ResourceGroupName myrg -VMName myacctVM
Reference: https://learn.microsoft.com/en-us/azure/virtual-machines/resource-graph-samples?tabs=azure-cli