question

RPeaks-9363 avatar image
0 Votes"
RPeaks-9363 asked ·

Virtual Machine Details

How can I list the VM's details like OS version (2008 2016 etc) SKU (A1 B2 ) processor type and number of cores (VCPU) for all the VM's in my subscription.

azure-virtual-machines
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

jakaruna-MSFT avatar image
0 Votes"
jakaruna-MSFT answered ·

You can list the VM name and sku by using azure resource graph.

With the sku details you can figure out the number of core used.

Sample command:

az graph query -q "Resources | where type =~ 'Microsoft.Compute/virtualMachines' | project name, location, type, properties.hardwareProfile.vmSize| order by name desc" --first <number of entries needed>

For getting details about the OS version, you need to login to the VM and execute commands to get the information.

· 1 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I am looking for specific info like this running natively on Azure CLI (for OS) az vm list --query '[].{ Name:name, offer:storageProfile.imageReference.offer, publisher:storageProfile.imageReference.publisher, sku:storageProfile.imageReference.sku, version:storageProfile.imageReference.version}'

This gives me all the list of VM with operating system.

Is there any code to get VCPU like the one mentioned above

0 Votes 0 · ·
RPeaks-9363 avatar image
0 Votes"
RPeaks-9363 answered ·

For anyone interested here how I was able to get the details.

function Get-AzureRMVMInfo { <# .SYNOPSIS Gets basic information on one or more Azure VMs.
.DESCRIPTION Get CPU, memory and IP configuration with a simple cmdlet. Pipeline input accepts multiple vm objects. .EXAMPLE Get-AzureRMVMInfo -VMName &#34;VM1&#34; -ResourceGroupName &#34;RG1&#34; This command gets the CPU, memory and internal IP for VM &#34;VM1&#34;. .EXAMPLE Get-AzureRMVM | Get-AzureRMVMInfo This command gets all VMs in the current subscription, then uses the output to surface all basic configuration on these VMs. .EXAMPLE Get-AzureRMVM | Get-AzureRMVMInfo | Sort &#34;Internal IP&#34; This command gets all VMs in the current subscription, then uses the output to surface all basic configuration on these VMs, sorted by Internal IP. [cmdletbinding(DefaultParameterSetName = 'Name')] Param(
[Parameter(Mandatory = $true, ParameterSetName = 'Name')] [string]$VMName, [Parameter(Mandatory = $true, ParameterSetName = 'Name')] [string]$ResourceGroupName, [Parameter(ValueFromPipeline, Mandatory = $true, ParameterSetName = 'Object')] $VM ) process { if ($pscmdlet.ParameterSetName -eq &#34;Name&#34;) { $vm = Get-AzureRMVM -Name $VMName -ResourceGroupName $ResourceGroupName }

     $sizeinfo = get-azurermvmsize -VMName $vm.name -ResourceGroupName $vm.ResourceGroupName | Where-Object {$_.Name -eq $vm.hardwareprofile.vmsize}
     $privateip = (Get-AzureRmNetworkInterface | where-Object {$_.Id -eq $vm.NetworkProfile.NetworkInterfaces[0].Id}).IpConfigurations[0].PrivateIPAddress
     $vminfo = [pscustomobject][ordered] @{
         Name          = $vm.Name
         CPU           = $sizeinfo.numberofcores
         &#34;Memory (GB)&#34; = $sizeinfo.MemoryInMB * 1mb / 1gb
         &#34;Internal IP&#34; = $privateip      
     }
     $vminfo
 }

}

· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.