Notă
Accesul la această pagină necesită autorizare. Puteți încerca să vă conectați sau să modificați directoarele.
Accesul la această pagină necesită autorizare. Puteți încerca să modificați directoarele.
API-ul de inventar îți permite să execuți interogări structurate pe Azure Resource Graph folosind o cerere POST cu o specificație de interogare în corpul cererii. API-ul traduce specificația interogării tale în Kusto Query Language (KQL) pentru execuție împotriva Azure Resource Graph. API-ul de inventar pentru resurse face parte din documentația de referință Power Platform API. Pentru o listă completă a tipurilor de resurse și a câmpurilor interogabile, consultați referința schemei de inventar Power Platform.
Punct final API
POST {PowerPlatformAPI url}/resourcequery/resources/query?api-version=2024-10-01
Corpul cererii
Corpul cererii trebuie să conțină o specificație de interogare cu următoarea structură:
Structura solicitării de interogare
{
"TableName": "string",
"Clauses": [
{
"$type": "clause_type",
// clause-specific properties
}
],
"Options": {
"Top": 100,
"Skip": 0,
"SkipToken": "string"
}
}
Proprietăți
| Proprietate | Tipul | Necesar | Descriere |
|---|---|---|---|
TableName |
string | Da | Tabelul/tipul de resursă țintă de interogat (de exemplu, "PowerPlatformResources") |
Clauses |
Matrice | Da | Matrice de clauze de interogare care definesc operațiunile de efectuat |
Options |
obiect | Nu | Opțiuni de interogare Azure Resource Graph pentru paginare și controlul rezultatelor |
Opțiuni de interogare
Obiectul Options suportă Azure Resource Graph parametri de interogare pentru paginare și controlul rezultatelor. Consultați ResourceQueryRequestOptions documentația pentru a afla mai multe.
Clauze de interogare acceptate
API-ul acceptă tipurile de clauze evidențiate în această secțiune prin serializare JSON polimorfă. Fiecare tip de clauză corespunde operatorilor KQL, așa cum este documentat în referința KQL:
Clauza Where
Filtrează datele în funcție de condițiile de teren. Se traduce în operatorul KQLwhere.
{
"$type": "where",
"FieldName": "string",
"Operator": "string",
"Values": ["string1", "string2"]
}
Operatori acceptați: API-ul acceptă toate comparațiile KQL standard și operatorii de șir. Pentru o listă completă a operatorilor disponibili, consultați documentația operatorilor de șir KQL și a operatorilor numerici .
Exemplu:
{
"$type": "where",
"FieldName": "type",
"Operator": "in~",
"Values": ["'microsoft.powerapps/canvasapps'", "'microsoft.copilotstudio/agents'"]
}
Se traduce în KQL:| where type in~ ('microsoft.powerapps/canvasapps', 'microsoft.copilotstudio/agents')
Clauza proiectului
Selectează anumite câmpuri din rezultate. Se traduce în operatorul KQLproject.
{
"$type": "project",
"FieldList": ["field1", "field2", "field3"]
}
Exemplu:
{
"$type": "project",
"FieldList": [
"name",
"properties.displayName",
"environmentId = tostring(properties.environmentId)",
"createdDate = properties.createdAt"
]
}
Se traduce în KQL:| project name, properties.displayName, environmentId = tostring(properties.environmentId), createdDate = properties.createdAt
Concluzia Take
Limitează numărul de rezultate returnate. Se traduce în operatorul KQLtake.
{
"$type": "take",
"TakeCount": 50
}
Se traduce în KQL:| take 50
Ordine după clauză
Sortează rezultatele după câmpurile specificate. Se traduce în operatorul KQLsort.
{
"$type": "orderby",
"FieldNamesAscDesc": {
"field1": "asc",
"field2": "desc"
}
}
Exemplu:
{
"$type": "orderby",
"FieldNamesAscDesc": {
"tostring(properties.createdAt)": "desc",
"properties.displayName": "asc"
}
}
Se traduce în KQL:| sort by tostring(properties.createdAt) desc, properties.displayName asc
Clauză distinctă
Returnează valori unice pentru câmpurile specificate. Se traduce în operatorul KQLdistinct.
{
"$type": "distinct",
"FieldList": ["field1", "field2"]
}
Se traduce în KQL:| distinct field1, field2
Clauza de numărare
Returnează numărul de înregistrări potrivite. Se traduce în operatorul KQLcount.
{
"$type": "count"
}
Se traduce în KQL:| count
Clauza de rezumat
Agregă datele folosind operațiuni count sau argmax. Se traduce în operatorul KQLsummarize.
{
"$type": "summarize",
"SummarizeClauseExpression": {
"OperatorName": "count|argmax",
"OperatorFieldName": "string",
"FieldList": ["field1", "field2"]
}
}
Operatori acceptați:
-
count→count()- Numără înregistrările grupate după câmpurile specificate. -
argmax→arg_max()- Obțineți înregistrări cu valoare maximă în câmpul specificat.
Exemplu de numărare:
{
"$type": "summarize",
"SummarizeClauseExpression": {
"OperatorName": "count",
"OperatorFieldName": "resourceCount",
"FieldList": ["resourceGroup", "type"]
}
}
Se traduce în KQL:| summarize resourceCount = count() by resourceGroup, type
Exemplu ArgMax:
{
"$type": "summarize",
"SummarizeClauseExpression": {
"OperatorName": "argmax",
"OperatorFieldName": "createdTime",
"FieldList": ["resourceGroup"]
}
}
Se traduce în KQL:| summarize arg_max(createdTime, *) by resourceGroup
Clauza de extindere
Adaugă coloane calculate la rezultate. Se traduce în operatorul KQLextend.
{
"$type": "extend",
"FieldName": "newFieldName",
"Expression": "KQL_EXPRESSION"
}
Exemplu:
{
"$type": "extend",
"FieldName": "environmentId",
"Expression": "tostring(properties.environmentId)"
}
Se traduce în KQL:| extend environmentId = tostring(properties.environmentId)https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/scalarfunctions) pentru funcțiile disponibile.
Clauza de alăturare
Se alătură unui alt tabel/subinterogare. Se traduce în operatorul KQLjoin.
{
"$type": "join",
"RightTable": {
"TableName": "string",
"Clauses": []
},
"JoinKind": "string",
"LeftColumnName": "string",
"RightColumnName": "string"
}
Tipuri de asociere acceptate: API-ul acceptă toate tipurile de asociere KQL. Pentru o listă completă a tipurilor de asociere disponibile și a comportamentului acestora, consultați documentația operatorului de îmbinare KQL.
Exemplu (asocierea resurselor Power Platform cu informații despre mediu):
{
"$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"
}
Se traduce în 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
Exemple complete de interogare
Exemplu: Interogare de resurse Power Platform de bază (model implicit Power Platform admin center)
Obține toate resursele Power Platform cu informații despre mediu — aceasta este interogarea implicită folosită de centrul de administrare 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 echivalent:
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
Exemplu: Numără resursele Power Platform după tip și locație
{
"TableName": "PowerPlatformResources",
"Clauses": [
{
"$type": "summarize",
"SummarizeClauseExpression": {
"OperatorName": "count",
"OperatorFieldName": "resourceCount",
"FieldList": ["type", "location"]
}
},
{
"$type": "orderby",
"FieldNamesAscDesc": {
"resourceCount": "desc"
}
}
]
}
KQL echivalent:
PowerPlatformResources
| summarize resourceCount = count() by type, location
| sort by resourceCount desc
Exemplu: Interogare simplă a aplicațiilor canvas
Obțineți aplicații proiectate pe pânză cu filtrare și proiecție de bază:
{
"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 echivalent:
PowerPlatformResources
| where type == 'microsoft.powerapps/canvasapps'
| project name, location, properties.displayName, properties.createdAt, properties.environmentId
| take 100
Exemplu: Filtrează resursele după mediu și interval de date
{
"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"
}
}
]
}
Se traduce în 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
Formatul răspunsului
API-ul returnează un obiect ResourceQueryResult din SDK-ul Azure Resource Graph. Acest obiect conține rezultatele interogării și metadatele despre execuția interogării.
Structura răspunsului:
{
"totalRecords": 1250,
"count": 50,
"resultTruncated": 1,
"skipToken": "string_for_next_page",
"data": [
// Array of result objects based on your query
]
}