Search code examples
azurekqlazure-resource-graph

azure kql to get OSversion and OSName from VMSS


resources
 | where type == "microsoft.compute/virtualmachinescalesets"
 | extend
extensions = properties.virtualMachineProfile.extensionProfile.extensions,
osName = properties.virtualMachineProfile.storageProfile.osDisk.osName,
osVersion = properties.virtualMachineProfile.storageProfile.osDisk.osVersion,
osType = properties.virtualMachineProfile.storageProfile.osDisk.osType

I can get osType which "Linux" but I want OSName (like ubuntu, Redhut) osVersion( like version 18, 19)
what I need to do to get that.


Solution

  • resources
    |   where   type == "microsoft.compute/virtualmachinescalesets"
    |   extend  publisher   = properties.virtualMachineProfile.storageProfile.imageReference.publisher
               ,version     = properties.virtualMachineProfile.storageProfile.imageReference.version
               ,sku         = properties.virtualMachineProfile.storageProfile.imageReference.sku
               ,offer       = properties.virtualMachineProfile.storageProfile.imageReference.offer
    

    P.S.

    Here is a "tool" that you might find useful:

    resources
    | where type == "microsoft.compute/virtualmachinescalesets"
    | where * has "ubuntu"