Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Azure Resource Graph är en Azure-tjänst som gör att du kan fråga i stor skala, vilket hjälper dig att effektivt styra din miljö. Frågor skapas med Kusto Query Language (KQL). Mer information finns i Förstå Azure Resource Graph-frågespråket.
Den här sidan innehåller en lista över Exempel på Azure Resource Graph-frågor för Azure Arc-aktiverade Kubernetes. Du kan köra dessa frågor via Azure PowerShell eller Azure CLI eller i Azure-portalen med hjälp av Resource Graph Explorer. Ändra frågorna så att de passar dina behov.
Tips/Råd
Du kan använda Microsoft Copilot i Azure för att skapa Azure Resource Graph-frågor med naturligt språk. Mer information finns i Hämta resursinformation med Hjälp av Microsoft Copilot i Azure.
Exempelfrågor
Visa en lista över alla Azure Arc-aktiverade Kubernetes-resurser
Returnerar en lista över varje Azure Arc-aktiverat Kubernetes-kluster och relevanta metadata för varje kluster.
Resources
| project id, subscriptionId, location, type, properties.agentVersion, properties.kubernetesVersion, properties.distribution, properties.infrastructure, properties.totalNodeCount, properties.totalCoreCount
| where type =~ 'Microsoft.Kubernetes/connectedClusters'
az graph query -q "Resources | project id, subscriptionId, location, type, properties.agentVersion, properties.kubernetesVersion, properties.distribution, properties.infrastructure, properties.totalNodeCount, properties.totalCoreCount | where type =~ 'Microsoft.Kubernetes/connectedClusters'"
Visa en lista över alla Azure Arc-aktiverade Kubernetes-kluster med Azure Monitor-tillägget
Returnerar det anslutna kluster-ID:t för varje Azure Arc-aktiverat Kubernetes-kluster som har Azure Monitor-tillägget installerat.
KubernetesConfigurationResources
| where type == 'microsoft.kubernetesconfiguration/extensions'
| where properties.ExtensionType == 'microsoft.azuremonitor.containers'
| parse id with connectedClusterId '/providers/Microsoft.KubernetesConfiguration/Extensions' *
| project connectedClusterId
az graph query -q "KubernetesConfigurationResources | where type == 'microsoft.kubernetesconfiguration/extensions' | where properties.ExtensionType == 'microsoft.azuremonitor.containers' | parse id with connectedClusterId '/providers/Microsoft.KubernetesConfiguration/Extensions' * | project connectedClusterId"
Visa en lista över alla Azure Arc-aktiverade Kubernetes-kluster utan Azure Monitor-tillägg
Returnerar det anslutna kluster-ID:t för varje Azure Arc-aktiverat Kubernetes-kluster som saknar Azure Monitor-tillägget.
Resources
| where type =~ 'Microsoft.Kubernetes/connectedClusters' | extend connectedClusterId = tolower(id) | project connectedClusterId
| join kind = leftouter
(KubernetesConfigurationResources
| where type == 'microsoft.kubernetesconfiguration/extensions'
| where properties.ExtensionType == 'microsoft.azuremonitor.containers'
| parse tolower(id) with connectedClusterId '/providers/microsoft.kubernetesconfiguration/extensions' *
| project connectedClusterId
) on connectedClusterId
| where connectedClusterId1 == ''
| project connectedClusterId
az graph query -q "Resources | where type =~ 'Microsoft.Kubernetes/connectedClusters' | extend connectedClusterId = tolower(id) | project connectedClusterId | join kind = leftouter (KubernetesConfigurationResources | where type == 'microsoft.kubernetesconfiguration/extensions' | where properties.ExtensionType == 'microsoft.azuremonitor.containers' | parse tolower(id) with connectedClusterId '/providers/microsoft.kubernetesconfiguration/extensions' * | project connectedClusterId ) on connectedClusterId | where connectedClusterId1 == '' | project connectedClusterId"
Visa en lista över alla kluster som innehåller en Flux-konfiguration
Återger ID:erna för connectedCluster
och managedCluster
för kluster som innehåller minst en fluxConfiguration
.
resources
| where type =~ 'Microsoft.Kubernetes/connectedClusters' or type =~ 'Microsoft.ContainerService/managedClusters' | extend clusterId = tolower(id) | project clusterId
| join
( kubernetesconfigurationresources
| where type == 'microsoft.kubernetesconfiguration/fluxconfigurations'
| parse tolower(id) with clusterId '/providers/microsoft.kubernetesconfiguration/fluxconfigurations' *
| project clusterId
) on clusterId
| project clusterId
az graph query -q "resources | where type =~ 'Microsoft.Kubernetes/connectedClusters' or type =~ 'Microsoft.ContainerService/managedClusters' | extend clusterId = tolower(id) | project clusterId | join ( kubernetesconfigurationresources | where type == 'microsoft.kubernetesconfiguration/fluxconfigurations' | parse tolower(id) with clusterId '/providers/microsoft.kubernetesconfiguration/fluxconfigurations' * | project clusterId ) on clusterId | project clusterId"
Visa en lista över alla Flux-konfigurationer i ett icke-kompatibelt tillstånd
fluxConfiguration
Returnerar ID:t för konfigurationer som inte kan synkronisera resurser i klustret.
kubernetesconfigurationresources
| where type == 'microsoft.kubernetesconfiguration/fluxconfigurations'
| where properties.complianceState == 'Non-Compliant'
| project id
az graph query -q "kubernetesconfigurationresources | where type == 'microsoft.kubernetesconfiguration/fluxconfigurations' | where properties.complianceState == 'Non-Compliant' | project id"
Nästa steg
- Läs mer om frågespråket för Azure Resource Graph.
- Läs mer om att utforska resurser med Resource Graph.