【问题标题】:Azure Resource Graph Explorer - Query Azure VM descriptions, OS, sku - I need to join to columns (OS and sku in one)Azure Resource Graph Explorer - 查询 Azure VM 描述、OS、sku - 我需要加入列(OS 和 sku 合二为一)
【发布时间】:2021-01-20 18:47:26
【问题描述】:

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

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

这是我的 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, sku, name, 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, sku, vnetName=subnet_resource_id[8], subnetName=subnet_resource_id[10], ipAddress

这是我的结果:

我需要这样的:

谁能帮帮我,非常感谢。

我尝试使用“联合”运算符,但无法使用。

我已经使用了这些参考链接:

Azure Docs Link 1

Azure Docs Link 2

Azure Docs Link 3

【问题讨论】:

    标签: azure graph kql


    【解决方案1】:

    如果你想组合两个字符串 - 你可以使用 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, sku, name, 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
    

    【讨论】:

    • Woowww @Alexander Sloutsky ,非常感谢!有用!!!上帝保佑你。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-06
    • 1970-01-01
    • 2023-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-25
    相关资源
    最近更新 更多