Azure资源图资源管理器-查询Azure VM描述,操作系统,sku-我需要加入列将OS和sku合二为一

问题描述

我有一个问题。我想知道如何将两列合为一体。

我想将名称为“ OS”的“ OS”和“ sku”列合并为一个

这是我的KQL: Kusto Query on Azure Resource Graph

Resources
| where type == "microsoft.compute/virtualmachines"
| extend OS = properties.storageProfile.imageReference.offer
| extend sku = properties.storageProfile.imageReference.sku
| project OS, sku, name, nic = (properties.networkProfile.networkInterfaces)
| mvexpand nic
| project OS, nic_id = tostring(nic.id)
| join (
    Resources 
    | where type == "microsoft.network/networkinterfaces" 
    | project nic_id = tostring(id), properties) on nic_id
    | mvexpand ipconfig = (properties.ipConfigurations)
    | extend subnet_resource_id = split(tostring(ipconfig.properties.subnet.id), '/'), ipAddress = ipconfig.properties.privateIPAddress
    | order by name desc
| project vmName=(name), OS, vnetName=subnet_resource_id[8], subnetName=subnet_resource_id[10], ipAddress

这是我的结果:

the result image

我需要这样:

the desired output img

任何人都可以帮助我,非常感谢。

我尝试使用“联合”运算符,但无法使其正常工作。

我使用了以下参考链接

Azure Docs Link 1

Azure Docs Link 2

Azure Docs Link 3

解决方法

如果要合并两个字符串-可以使用strcat()函数:

 Resources
| where type == "microsoft.compute/virtualmachines"
| extend OS = properties.storageProfile.imageReference.offer
| extend sku = properties.storageProfile.imageReference.sku
| project OS,sku,name,nic = (properties.networkProfile.networkInterfaces)
| mvexpand nic
| project OS,nic_id = tostring(nic.id)
| join (
    Resources 
    | where type == "microsoft.network/networkinterfaces" 
    | project nic_id = tostring(id),properties) on nic_id
    | mvexpand ipconfig = (properties.ipConfigurations)
    | extend subnet_resource_id = split(tostring(ipconfig.properties.subnet.id),'/'),ipAddress = ipconfig.properties.privateIPAddress
    | order by name desc
| project vmName=(name),OS = strcat(OS,' ',sku),vnetName=subnet_resource_id[8],subnetName=subnet_resource_id[10],ipAddress