Power Platform インベントリ API

インベントリ API を使用すると、要求本文にクエリの指定がある POST 要求を使用して、Azure Resource Graph に対して構造化クエリを実行できます。 この API は、Azure Resource Graph に対して実行するために、クエリ仕様を Kusto クエリ言語 (KQL) に変換します。 リソースのインベントリ API は、Power Platform API リファレンス ドキュメントの一部です。 リソースの種類とクエリ可能なフィールドの完全な一覧については、「 Power Platform インベントリ スキーマ リファレンス」を参照してください

API エンドポイント


POST {PowerPlatformAPI url}/resourcequery/resources/query?api-version=2024-10-01

リクエスト本文

要求本文には、次の構造のクエリ仕様が含まれている必要があります。

クエリ要求の構造

{
  "TableName": "string",
  "Clauses": [
    {
      "$type": "clause_type",
      // clause-specific properties
    }
  ],
  "Options": {
    "Top": 100,
    "Skip": 0,
    "SkipToken": "string"
  }
}

プロパティ

財産 タイプ 必須 Description
TableName 文字列 Yes クエリ対象のテーブル/リソースの種類 ("PowerPlatformResources" など)
Clauses アレイ Yes 実行する操作を定義するクエリ句の配列
Options オブジェクト No ページ分割と結果制御のための Azure Resource Graph クエリ オプション

クエリ オプション

Options オブジェクトは、ページネーションおよび結果制御のためにAzure Resource Graphクエリパラメーターをサポートします。 詳細についてはResourceQueryRequestOptionsドキュメントを参照してください。

サポートされているクエリ句

API では、ポリモーフィックな JSON シリアル化によって、このセクションで強調表示されている句の種類がサポートされています。 各句の種類は、KQL リファレンスに記載されている KQL 演算子に対応します。

WHERE 句

フィールド条件に基づいてデータをフィルター処理します。 KQL where 演算子に変換します。

{
  "$type": "where",
  "FieldName": "string",
  "Operator": "string",
  "Values": ["string1", "string2"]
}

サポートされる演算子: API では、すべての標準的な KQL 比較演算子と文字列演算子がサポートされています。 使用可能な演算子の完全な一覧については、 KQL 文字列演算子数値演算子 のドキュメントを参照してください。

Example:

{
  "$type": "where",
  "FieldName": "type",
  "Operator": "in~",
  "Values": ["'microsoft.powerapps/canvasapps'", "'microsoft.copilotstudio/agents'"]
}

KQL に変換します。| where type in~ ('microsoft.powerapps/canvasapps', 'microsoft.copilotstudio/agents')

プロジェクト句

結果から特定のフィールドを選択します。 KQL project 演算子に変換します。

{
  "$type": "project",
  "FieldList": ["field1", "field2", "field3"]
}

Example:

{
  "$type": "project",
  "FieldList": [
    "name", 
    "properties.displayName", 
    "environmentId = tostring(properties.environmentId)",
    "createdDate = properties.createdAt"
  ]
}

KQL に変換します。| project name, properties.displayName, environmentId = tostring(properties.environmentId), createdDate = properties.createdAt

Take 句

返される結果の数を制限します。 KQL take 演算子に変換します。

{
  "$type": "take",
  "TakeCount": 50
}

KQL に変換します。| take 50

Order by 句

指定したフィールドで結果を並べ替えます。 KQL sort 演算子に変換します。


{
  "$type": "orderby",
  "FieldNamesAscDesc": {
    "field1": "asc",
    "field2": "desc"
  }
}

Example:

{
  "$type": "orderby",
  "FieldNamesAscDesc": {
    "tostring(properties.createdAt)": "desc",
    "properties.displayName": "asc"
  }
}

KQL に変換します。| sort by tostring(properties.createdAt) desc, properties.displayName asc

Distinct 句

指定したフィールドの一意の値を返します。 KQL distinct 演算子に変換します。


{
  "$type": "distinct",
  "FieldList": ["field1", "field2"]
}

KQL に変換します。| distinct field1, field2

カウント句

一致するレコードの数を返します。 KQL count 演算子に変換します。

{
  "$type": "count"
}

KQL に変換します。| count

要約句

count または argmax 操作を使用してデータを集計します。 KQL summarize 演算子に変換します。

{
  "$type": "summarize",
  "SummarizeClauseExpression": {
    "OperatorName": "count|argmax",
    "OperatorFieldName": "string",
    "FieldList": ["field1", "field2"]
  }
}

サポートされる演算子:

  • countcount() - 指定したフィールドでグループ化されたレコードをカウントします。
  • argmaxarg_max() - 指定したフィールドの最大値を持つレコードを取得します。

カウントの例:

{
  "$type": "summarize",
  "SummarizeClauseExpression": {
    "OperatorName": "count",
    "OperatorFieldName": "resourceCount",
    "FieldList": ["resourceGroup", "type"]
  }
}

KQL に変換します。| summarize resourceCount = count() by resourceGroup, type

ArgMax の例:

{
  "$type": "summarize",
  "SummarizeClauseExpression": {
    "OperatorName": "argmax",
    "OperatorFieldName": "createdTime",
    "FieldList": ["resourceGroup"]
  }
}

KQL に変換します。| summarize arg_max(createdTime, *) by resourceGroup

拡張節

計算列を結果に追加します。 KQL extend 演算子に変換します。

{
  "$type": "extend",
  "FieldName": "newFieldName",
  "Expression": "KQL_EXPRESSION"
}

Example:

{
  "$type": "extend",
  "FieldName": "environmentId",
  "Expression": "tostring(properties.environmentId)"
}

| extend environmentId = tostring(properties.environmentId) 使用可能な関数の場合は、KQL:https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/scalarfunctions) に変換します。

Join 句

別のテーブル/サブクエリと結合します。 KQL join 演算子に変換します。


{
  "$type": "join",
  "RightTable": {
    "TableName": "string",
    "Clauses": []
  },
  "JoinKind": "string",
    "LeftColumnName": "string",
  "RightColumnName": "string"
}

サポートされている結合の種類: API では、すべての KQL 結合の種類がサポートされています。 使用可能な結合の種類とその動作の完全な一覧については、 KQL 結合演算子のドキュメントを参照してください

例 (Power Platform リソースと環境情報の結合):

{
  "$type": "join",
  "JoinKind": "leftouter",
  "RightTable": {
    "TableName": "PowerPlatformResources",
    "Clauses": [
      {
        "$type": "where",
        "FieldName": "type",
        "Operator": "==",
        "Values": ["'microsoft.powerplatform/environments'"]
      },
      {
        "$type": "project",
        "FieldList": [
          "environmentId = name",
          "environmentName = properties.displayName",
          "environmentRegion = location",
          "environmentType = properties.environmentType",
          "isManagedEnvironment = properties.isManaged"
        ]
      }
    ]
  },
  "LeftColumnName": "environmentId",
  "RightColumnName": "environmentId"
}

KQL に変換します。| join kind=leftouter (PowerPlatformResources | where type == 'microsoft.powerplatform/environments' | project environmentId = name, environmentName = properties.displayName, environmentRegion = location, environmentType = properties.environmentType, isManagedEnvironment = properties.isManaged) on $left.environmentId == $right.environmentId

完全なクエリの例

例: 基本的な Power Platform リソース クエリ (Power Platform 管理センターの既定のパターン)

環境情報を含むすべての Power Platform リソースを取得します。これは、Power Platform 管理センターで使用される既定のクエリです。

{
  "Options": {
    "Top": 1000,
    "Skip": 0,
    "SkipToken": ""
  },
  "TableName": "PowerPlatformResources",
  "Clauses": [
    {
      "$type": "extend",
      "FieldName": "joinKey",
      "Expression": "tolower(tostring(properties.environmentId))"
    },
    {
      "$type": "join",
      "JoinKind": "leftouter",
      "RightTable": {
        "TableName": "PowerPlatformResources",
        "Clauses": [
          {
            "$type": "where",
            "FieldName": "type",
            "Operator": "==",
            "Values": ["'microsoft.powerplatform/environments'"]
          },
            {
            "$type": "project",
            "FieldList": [
              "joinKey = tolower(name)",
              "environmentName = properties.displayName",
              "environmentRegion = location",
              "environmentType = properties.environmentType",
              "isManagedEnvironment = properties.isManaged"
            ]
          }
        ]
      },
      "LeftColumnName": "joinKey",
      "RightColumnName": "joinKey"
    },
    {
      "$type": "where",
      "FieldName": "type",
      "Operator": "in~",
      "Values": [
        "'microsoft.powerapps/canvasapps'",
        "'microsoft.powerapps/modeldrivenapps'",
        "'microsoft.powerautomate/cloudflows'",
        "'microsoft.copilotstudio/agents'",
        "'microsoft.powerautomate/agentflows'",
        "'microsoft.powerapps/codeapps'"
      ]
    },
    {
      "$type": "orderby",
      "FieldNamesAscDesc": {
        "tostring(properties.createdAt)": "desc"
      }
    }
  ]
}

同等の KQL:

PowerPlatformResources
| extend joinKey = tolower(tostring(properties.environmentId))
| join kind=leftouter (
    PowerPlatformResources
    | where type == 'microsoft.powerplatform/environments'
    | project joinKey = tolower(name), environmentName = properties.displayName, environmentRegion = location, environmentType = properties.environmentType, isManagedEnvironment = properties.isManaged
  ) on $left.joinKey == $right.joinKey
| where type in~ ('microsoft.powerapps/canvasapps', 'microsoft.powerapps/modeldrivenapps', 'microsoft.powerautomate/cloudflows', 'microsoft.copilotstudio/agents', 'microsoft.powerautomate/agentflows', 'microsoft.powerapps/codeapps')
| order by tostring(properties.createdAt) desc

例: 種類と場所別に Power Platform リソースをカウントする

{
  "TableName": "PowerPlatformResources",
  "Clauses": [
    {
      "$type": "summarize",
      "SummarizeClauseExpression": {
        "OperatorName": "count",
        "OperatorFieldName": "resourceCount",
        "FieldList": ["type", "location"]
      }
    },
    {
      "$type": "orderby",
      "FieldNamesAscDesc": {
        "resourceCount": "desc"
      }
    }
  ]
}

同等の KQL:

PowerPlatformResources
| summarize resourceCount = count() by type, location
| sort by resourceCount desc

例: 単純なキャンバス アプリのクエリ

基本的なフィルター処理とプロジェクションを使用してキャンバス アプリを取得します。

{
  "TableName": "PowerPlatformResources",
  "Clauses": [
    {
      "$type": "where",
      "FieldName": "type",
      "Operator": "==",
      "Values": ["'microsoft.powerapps/canvasapps'"]
    },
    {
      "$type": "project",
      "FieldList": [
        "name",
        "location",
        "properties.displayName",
        "properties.createdAt",
        "properties.environmentId"
      ]
    },
    {
      "$type": "take",
      "TakeCount": 100
    }
  ]
}

同等の KQL:

PowerPlatformResources
| where type == 'microsoft.powerapps/canvasapps'
| project name, location, properties.displayName, properties.createdAt, properties.environmentId
| take 100

例: 環境と日付範囲でリソースをフィルター処理する

{
  "TableName": "PowerPlatformResources",
  "Clauses": [
    {
      "$type": "where",
      "FieldName": "type",
      "Operator": "==",
      "Values": ["'microsoft.powerapps/canvasapps'"]
    },
    {
      "$type": "where",
      "FieldName": "properties.environmentId",
      "Operator": "==",
      "Values": ["your-environment-id"]
    },
    {
      "$type": "extend",
      "FieldName": "createdDate",
      "Expression": "todatetime(properties.createdAt)"
    },
    {
      "$type": "where",
      "FieldName": "createdDate",
      "Operator": ">=",
      "Values": ["datetime(2024-01-01)"]
    },
    {
      "$type": "project",
      "FieldList": [
        "name",
        "properties.displayName",
        "properties.createdAt",
        "properties.createdBy",
        "properties.ownerId"
      ]
    },
    {
      "$type": "orderby",
      "FieldNamesAscDesc": {
        "createdDate": "desc"
      }
    }
  ]
}

KQL に変換します。

PowerPlatformResources
| where type == 'microsoft.powerapps/canvasapps'
| where properties.environmentId == "your-environment-id"
| extend createdDate = todatetime(properties.createdAt)
| where createdDate >= datetime(2024-01-01)
| project name, properties.displayName, properties.createdAt, properties.createdBy, properties.ownerId
| sort by createdDate desc

応答形式

この API は、Azure Resource Graph SDK から ResourceQueryResult オブジェクトを返します。 このオブジェクトには、クエリの結果とクエリ実行に関するメタデータが含まれています。

応答の構造:

{
  "totalRecords": 1250,
  "count": 50,
  "resultTruncated": 1,
  "skipToken": "string_for_next_page",
  "data": [
    // Array of result objects based on your query
  ]
}