Power Platform 清单示例查询

以下示例查询针对 Azure Resource Graph 中的 PowerPlatformResources 表运行。 它们涵盖资源计数和分布、字段发现、资源查找和连接器使用情况分析。 有关 Power Platform 清单的概述,请参阅 Power Platform 清单。 有关架构和字段参考,请参阅 Power Platform 清单架构参考。

如何运行这些查询

可以从Azure Resource Graph接口运行其中的任何查询。 有关分步说明,请参阅以下快速入门指南:

计数和分布

所有资源的总数

PowerPlatformResources
| count

按资源类型统计的总计数

PowerPlatformResources
| summarize resourceCount = count() by type
| order by resourceCount

按环境计数

PowerPlatformResources
| extend properties = parse_json(properties)
| extend environmentId = tostring(properties.environmentId)
| summarize resourceCount = count() by environmentId
| order by resourceCount desc

按区域计数

PowerPlatformResources
| summarize resourceCount = count() by location
| order by resourceCount desc

按项目数量排名靠前的所有者

PowerPlatformResources
| extend properties = parse_json(properties)
| extend ownerId = tostring(properties.ownerId)
| summarize resourceCount = count() by ownerId
| order by resourceCount desc

资源查找

在租户中查找单个代理

PowerPlatformResources
| where type == "microsoft.copilotstudio/agents"
| where name == "[Enter the agent's ID]"

Tip

查看代理时或在清单表的 “名称 ”列中,可以在 Copilot Studio URL 中找到代理的 ID。

按框架统计智能体

显示使用 GitHub Copilot 框架、Copilot 对话助手框架或标准框架创建的智能体的详细分类。

您可以在 Power Platform 管理中心的框架列中查看智能体的框架,该列位于管理>Copilot Studio 下。 该列只是用户界面列。 Harness 尚未作为代理元数据返回,因此此查询会根据清单返回的字段推导出 Harness:properties.isCLIAgent、properties.model 和 properties.createdIn。 当 properties.harness 字段变为可用时,可以改为直接查询它。 有关字段定义,请参阅Microsoft Copilot Studio代理清单架构。

PowerPlatformResources
| where type == "microsoft.copilotstudio/agents"
| extend properties = parse_json(properties)
| extend
    isCLIAgent = tobool(properties.isCLIAgent),
    model = tostring(properties.model),
    createdIn = tostring(properties.createdIn)
| extend harness = case(
    isCLIAgent == true, "GitHub Copilot",
    model =~ "Microsoft 365 Copilot" or createdIn =~ "Microsoft 365 Copilot Agent Builder", "Copilot Chat",
    "Standard")
| summarize agentCount = count() by harness
| order by agentCount desc

按框架列出智能体

为每个智能体返回一行数据及其所属框架,以便您不仅能统计智能体数量,还能查找并针对单个智能体采取操作。 取消对 where 这一行的注释,以便仅返回使用 GitHub Copilot harness 构建的代理。

PowerPlatformResources
| where type == "microsoft.copilotstudio/agents"
| extend properties = parse_json(properties)
| extend
    isCLIAgent = tobool(properties.isCLIAgent),
    model = tostring(properties.model),
    createdIn = tostring(properties.createdIn)
| extend harness = case(
    isCLIAgent == true, "GitHub Copilot",
    model =~ "Microsoft 365 Copilot" or createdIn =~ "Microsoft 365 Copilot Agent Builder", "Copilot Chat",
    "Standard")
//| where harness == "GitHub Copilot"
| project agentName = tostring(properties.displayName),
          agentId = name,
          harness,
          environmentId = tostring(properties.environmentId),
          ownerId = tostring(properties.ownerId),
          createdAt = todatetime(properties.createdAt)
| order by harness asc, createdAt desc

在过去 24 小时内创建的项目

PowerPlatformResources
| extend properties = parse_json(properties)
| extend createdAt = todatetime(properties.createdAt)
| where createdAt >= ago(24h)

连接器查询(预览版)

以下查询分析连接器清单涵盖的资源类型的连接器使用情况(预览版)。 每个查询都对由画布应用、模型驱动应用、云流、代理流、工作流代理流和 Copilot Studio 代理输出的 properties.powerPlatformConnectors 数组执行操作。

整个 Power Platform 资源中使用的最常用连接器

列出最不同的资源使用的连接器。 有助于了解哪些连接器主导整个租户的采用。

PowerPlatformResources
| where type in (
    "microsoft.powerapps/canvasapps",
    "microsoft.powerapps/modeldrivenapps",
    "microsoft.powerautomate/cloudflows",
    "microsoft.powerautomate/agentflows",
    "microsoft.powerautomate/m365agentflows",
    "microsoft.copilotstudio/agents")
| extend properties = parse_json(properties)
| mv-expand connector = properties.powerPlatformConnectors
| extend connectorId = tostring(connector.connectorId)
| where isnotempty(connectorId)
| summarize ResourceCount = dcount(name) by connectorId
| order by ResourceCount desc
| take 10

每个资源的连接器计数分布

显示有多少资源使用 0、1、2 或更多连接器。 有助于识别复杂度异常值。

PowerPlatformResources
| where type in (
    "microsoft.powerapps/canvasapps",
    "microsoft.powerapps/modeldrivenapps",
    "microsoft.powerautomate/cloudflows",
    "microsoft.powerautomate/agentflows",
    "microsoft.powerautomate/m365agentflows",
    "microsoft.copilotstudio/agents")
| extend properties = parse_json(properties)
| extend connectorCount = array_length(properties.powerPlatformConnectors)
| summarize ResourceCount = count() by toint(connectorCount)
| order by connectorCount asc

查找使用特定连接器的所有资源

用您要搜索的连接器替换 shared_sharepointonline。 当连接器存在已知问题、已弃用或需要新许可时,此查询对于影响分析非常有用。

PowerPlatformResources
| where type in (
    "microsoft.powerapps/canvasapps",
    "microsoft.powerapps/modeldrivenapps",
    "microsoft.powerautomate/cloudflows",
    "microsoft.powerautomate/agentflows",
    "microsoft.powerautomate/m365agentflows",
    "microsoft.copilotstudio/agents")
| extend properties = parse_json(properties)
| mv-expand connector = properties.powerPlatformConnectors
| where tostring(connector.connectorId) == "shared_sharepointonline"
| project resourceName = tostring(properties.displayName),
          resourceId = name,
          resourceType = type,
          environmentId = tostring(properties.environmentId),
          operationsUsed = connector.operations

按环境排序的连接器使用情况

列出每个环境中使用的每个连接器,以及使用该连接器的不同资源数量。 此列表有助于了解采用模式并通知 DLP 策略决策。

PowerPlatformResources
| where type in (
    "microsoft.powerapps/canvasapps",
    "microsoft.powerapps/modeldrivenapps",
    "microsoft.powerautomate/cloudflows",
    "microsoft.powerautomate/agentflows",
    "microsoft.powerautomate/m365agentflows",
    "microsoft.copilotstudio/agents")
| extend properties = parse_json(properties)
| mv-expand connector = properties.powerPlatformConnectors
| extend connectorId = tostring(connector.connectorId)
| where isnotempty(connectorId)
| extend environmentId = tostring(properties.environmentId)
| summarize ResourceCount = dcount(name) by environmentId, connectorId
| order by environmentId asc, ResourceCount desc