0

I'm trying to use azure graph with kusto query to get the agent version of a vm.
With REST API, we can do "/instanceView" to get vmAgent.vmAgentVersion

but with Azure Resource Graph explorer, the instanceView is limited to "PowerState".
I didn't find any way to have that information with kusto. Any suggestions ?

resources
| where type == "microsoft.compute/virtualmachines" 
David דודו Markovitz
  • 42,900
  • 6
  • 64
  • 88
kent2004
  • 59
  • 6

1 Answers1

0

Using Azure Resource Graph explorer, you will get:

resources
| project properties,
type
| where type == "microsoft.compute/virtualmachines"

Output:

instanceView": {
            "hyperVGeneration": "V1",
            "computerName": "ceuubfcv",
            "powerState": {
                "displayStatus": "VM running",
                "code": "PowerState/running",
                "level": "Info"
            },
            "osVersion": "18.04",
            "osName": "ubuntu"
        }
    },
    "vmId": "76vvgtchiufd4e"
}

enter image description here

Alternatively, you can use below PowerShell command to get vm version agent and I followed Microsoft-Document and @Rakhesh sasidharan's Blog:

$vio = (Invoke-AzRestMethod -Path ('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachines/{2}/instanceView?api-version=2021-11-01' -f "XX","YY","ZZ") -Method 'GET' | Select-Object -ExpandProperty Content | ConvertFrom-Json)
$vio
$vio.vmAgent  

XX-Subscription ID YY-Resourcegroup ZZ- Name Of VM

enter image description here

Using KQL, I found below query you can get agent id and some details of vm:

VMComputer 

So you can use Rest api , resource graph and powershell to get details of Vm. Using KQL all the details are not retrieved AFAIK.

RithwikBojja
  • 5,069
  • 2
  • 3
  • 7
  • I agreed about powershell rest api, that is what I already do, but it is slower (need to be done vm per vm). My question is to have that information via KQL directly, as I can have powers status for instance. You finish your answer by "VMComputer", what do you mean by that ? Thanks – kent2004 Nov 30 '22 at 07:53
  • [Reference](https://www.geeksforgeeks.org/microsoft-azure-kql-query-to-get-the-vm-computer-properties/) about VmComputer, Mostly AFAIK, Using KQL you cannot get the details you are looking for. – RithwikBojja Nov 30 '22 at 08:07