许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  Azure系列:Azure理念、操作与资源概述(启用Azure Arc服务器的资源图查询示例)

Azure系列:Azure理念、操作与资源概述(启用Azure Arc服务器的资源图查询示例)

阅读数 4
点赞 0
article_banner

Azure 资源图是一项 Azure 服务,可让您大规模查询,从而帮助您有效地管理环境。查询使用 Kusto 查询语言 (KQL) 创建。有关详细信息,请参阅了解 Azure 资源图查询语言。

本页面提供了适用于已启用 Azure Arc 的服务器的 Azure 资源图查询示例列表。您可以通过 Azure PowerShell 或 Azure CLI 运行这些查询,也可以在 Azure 门户中使用资源图资源管理器运行。您可以根据需要修改这些查询。

提示

您可以使用 Azure 中的 Microsoft Copilot,以自然语言编写 Azure 资源图查询。有关详细信息,请参阅在 Azure 中使用 Microsoft Copilot 获取资源信息。

示例查询

按域获取启用 Arc 的服务器数量和百分比

此查询汇总了Azure Arc 启用服务器domainName的属性,并使用计算创建了一列,用于显示每个域中启用 Arc 的服务器的百分比。binPct

库斯托

Resources
| where type == 'microsoft.hybridcompute/machines'
| project domain=tostring(properties.domainName)
| summarize Domains=make_list(domain), TotalMachineCount=sum(1)
| mvexpand EachDomain = Domains
| summarize PerDomainMachineCount = count() by tostring(EachDomain), TotalMachineCount
| extend Pct = 100 * bin(todouble(PerDomainMachineCount) / todouble(TotalMachineCount), 0.001)

  • Azure CLI
  • Azure PowerShell
  • 门户网站
  • Azure CLI
az graph query -q "Resources | where type == 'microsoft.hybridcompute/machines' | project domain=tostring(properties.domainName) | summarize Domains=make_list(domain), TotalMachineCount=sum(1) | mvexpand EachDomain = Domains | summarize PerDomainMachineCount = count() by tostring(EachDomain), TotalMachineCount | extend Pct = 100 * bin(todouble(PerDomainMachineCount) / todouble(TotalMachineCount), 0.001)"

列出 Azure Arc 服务器上安装的所有扩展程序

首先,此查询使用project混合机器资源类型获取大写的 ID toupper(),获取计算机名称以及机器上运行的操作系统。获取大写的资源 ID 有助于为join后续属性的获取做好准备。然后,查询使用join`with kindas`leftouter来获取substring扩展 ID 的大写部分。ID 的前半部分/extensions/与混合机器 ID 的格式相同,因此我们使用此属性join。summarize接下来,使用 `with as` 来获取虚拟机扩展的名称,将ID、操作系统名称和计算机名称相同的make_list扩展名称合并到一个数组属性中。最后,我们使用 `order` 按小写的操作系统名称排序。默认情况下,排序方式为降序。ascorder by

库斯托

Resources
| where type == 'microsoft.hybridcompute/machines'
| project
  id,
  JoinID = toupper(id),
  ComputerName = tostring(properties.osProfile.computerName),
  OSName = tostring(properties.osName)
| join kind=leftouter(
  Resources
  | where type == 'microsoft.hybridcompute/machines/extensions'
  | project
    MachineId = toupper(substring(id, 0, indexof(id, '/extensions'))),
    ExtensionName = name
) on $left.JoinID == $right.MachineId
| summarize Extensions = make_list(ExtensionName) by id, ComputerName, OSName
| order by tolower(OSName) asc

  • Azure CLI
  • Azure PowerShell
  • 门户网站
  • Azure CLI
az graph query -q "Resources | where type == 'microsoft.hybridcompute/machines' | project id, JoinID = toupper(id), ComputerName = tostring(properties.osProfile.computerName), OSName = tostring(properties.osName) | join kind=leftouter( Resources | where type == 'microsoft.hybridcompute/machines/extensions' | project  MachineId = toupper(substring(id, 0, indexof(id, '/extensions'))),  ExtensionName = name ) on \$left.JoinID == \$right.MachineId | summarize Extensions = make_list(ExtensionName) by id, ComputerName, OSName | order by tolower(OSName) asc"

列出未运行最新发布代理版本的启用 Arc 的服务器

此查询返回所有运行过时版本的连接计算机代理的启用 Arc 的服务器。状态为“已过期”的代理将从结果中排除。该查询会leftouter join汇总针对任何被识别为过时的连接计算机代理的 Advisor 建议,并筛选出一段时间内未与 Azure 通信的任何代理。

库斯托

AdvisorResources
| where type == 'microsoft.advisor/recommendations'
| where properties.category == 'HighAvailability'
| where properties.shortDescription.solution == 'Upgrade to the latest version of the Azure Connected Machine agent'
| project
    id,
    JoinId = toupper(properties.resourceMetadata.resourceId),
    machineName = tostring(properties.impactedValue),
    agentVersion = tostring(properties.extendedProperties.installedVersion),
    expectedVersion = tostring(properties.extendedProperties.latestVersion)
| join kind=leftouter(
  Resources
  | where type == 'microsoft.hybridcompute/machines'
  | project
    machineId = toupper(id),
    status = tostring (properties.status)
  ) on $left.JoinId == $right.machineId
| where status != 'Expired'
| summarize by id, machineName, agentVersion, expectedVersion
| order by tolower(machineName) asc

  • Azure CLI
  • Azure PowerShell
  • 门户网站
  • Azure CLI
az graph query -q "AdvisorResources | where type == 'microsoft.advisor/recommendations' | where properties.category == 'HighAvailability' | where properties.shortDescription.solution == 'Upgrade to the latest version of the Azure Connected Machine agent' | project  id,  JoinId = toupper(properties.resourceMetadata.resourceId),  machineName = tostring(properties.impactedValue),  agentVersion = tostring(properties.extendedProperties.installedVersion),  expectedVersion = tostring(properties.extendedProperties.latestVersion) | join kind=leftouter( Resources | where type == 'microsoft.hybridcompute/machines' | project  machineId = toupper(id),  status = tostring (properties.status) ) on \$left.JoinId == \$right.machineId | where status != 'Expired' | summarize by id, machineName, agentVersion, expectedVersion | order by tolower(machineName) asc"

列出已安装 SQL Server、PostgreSQL 或 MySQL 的启用 Arc 的服务器

此查询返回所有已安装 SQL Server、PostgreSQL 或 MySQL 的 Arc 服务器。

库斯托

resources
| where type =~ 'microsoft.hybridcompute/machines'
| extend machineId = tolower(tostring(id)), datacenter = iif(isnull(tags.Datacenter), '', tags.Datacenter), status = tostring(properties.status)
| extend mssqlinstalled = coalesce(tobool(properties.detectedProperties.mssqldiscovered),false)
| extend pgsqlinstalled = coalesce(tobool(properties.detectedProperties.pgsqldiscovered),false)
| extend mysqlinstalled = coalesce(tobool(properties.detectedProperties.mysqldiscovered),false)
| extend osSku = properties.osSku, osName = properties.osName, osVersion = properties.osVersion
| extend coreCount = tostring(properties.detectedProperties.logicalCoreCount), totalPhysicalMemoryinGB = tostring(properties.detectedProperties.totalPhysicalMemoryInGigabytes) 
| extend operatingSystem = iif(isnotnull(osSku), osSku, osName)
| where mssqlinstalled or mysqlinstalled or pgsqlinstalled
| project id ,name, type, resourceGroup, subscriptionId, location, kind, osVersion, status, osSku,coreCount,totalPhysicalMemoryinGB,tags, mssqlinstalled, mysqlinstalled, pgsqlinstalled
| sort by (tolower(tostring(name))) asc

  • Azure CLI
  • Azure PowerShell
  • 门户网站
  • Azure CLI
az graph query -q "resources | where type =~ 'microsoft.hybridcompute/mac



免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删

相关文章
技术文档
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空