简体   繁体   English

Azure Resource Graph Explorer - 查询 Azure VM 描述、OS、sku - 我需要加入列(OS 和 sku 合二为一)

[英]Azure Resource Graph Explorer - Query Azure VM descriptions, OS, sku - I need to join to columns (OS and sku in one)

I have a issue.我有一个问题。 I want to know how can I join two columns in one.我想知道如何将两列合二为一。

I want to join the "OS" and "sku" columns in one with the name "OS"我想将名称为“OS”的“OS”和“sku”列合二为一

This is my KQL: Kusto Query on Azure Resource Graph这是我的 KQL: Azure 资源图上的 Kusto 查询

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

This is my result:这是我的结果:

结果图像

I need like this:我需要这样:

所需的输出 img

Can anyone help me, thanks so much.谁能帮帮我,非常感谢。

I've tried to use the "union" operator, but I can't make it work.我试过使用“联合”运算符,但我不能让它工作。

I have used these reference link:我使用了这些参考链接:

Azure Docs Link 1 Azure 文档链接 1

Azure Docs Link 2 Azure 文档链接 2

Azure Docs Link 3 Azure 文档链接 3

If you want to combine two strings - you can use strcat() function:如果你想组合两个字符串 - 你可以使用 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure 从 Azure 门户导出 VM 详细信息(订阅、资源组、spn、vm-name,使用 window 操作系统 SKU)的 Devops 管道 - Azure Devops pipeline that export VM details(subscription, resource group, spn, vm-name, with window operating system SKU) from Azure portal 使用 Azure SDK 为 Z303CB0EF9EDB9082AZD61BBBE52 获取 Azure 资源 SKU - Get Azure resource SKU using the Azure SDK for .NET 在 Azure 中,我想使用 Python SDK 获取特定 VM 的 sku 列表 - In Azure I wanted to get sku list for a specific VM using Python SDK 我可以升级 azure 中虚拟机的操作系统吗? - Can I upgrade the OS of a vm in azure? 获取Azure自动化帐户的Sku - Get the Sku of Azure automation account Azure VM:操作系统磁盘大小 - Azure VM: OS disk size Azure VM OS构建-Powershell - Azure VM OS Build - Powershell 我如何在 Azure 中获取使用基本 SKU 的资源列表? - How can i get a list of resources that use Basic SKU in Azure? Azure 资源图查询 - Azure Resource Graph query 尝试在 Azure 和 Terraform 中创建 Linux VM 规模集时收到“无效参数”SKU 错误 - Receiving a 'Invalid Parameter' SKU error when trying to create a Linux VM Scale Set in Azure with Terraform
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM