Ukázkové dotazy Azure Resource Graphu pro Kubernetes s podporou Služby Azure Arc

Tato stránka je kolekce ukázkových dotazů Azure Resource Graphu pro Kubernetes s podporou Azure Arc. Úplný seznam ukázek Azure Resource Graphu najdete v ukázkách Resource Graphu podle kategorií a ukázek Resource Graphu podle tabulky.

Vzorové dotazy

Výpis všech clusterů Kubernetes s podporou Azure Arc s rozšířením Azure Monitoru

Vrátí ID připojeného clusteru každého clusteru Kubernetes s podporou Azure Arc, který má nainstalované rozšíření Azure Monitor.

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"

Výpis všech clusterů Kubernetes s podporou Azure Arc bez rozšíření Azure Monitoru

Vrátí ID připojeného clusteru každého clusteru Kubernetes s podporou Služby Azure Arc, ve které chybí rozšíření Azure Monitoru.

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"

Výpis všech prostředků Kubernetes s podporou Služby Azure Arc

Vrátí seznam všech clusterů Kubernetes s podporou Azure Arc a relevantních metadat pro každý cluster.

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'"

Zobrazit seznam všech Připojení Clusters a ManagedClusters, které obsahují flux Configuration

Vrátí connectedCluster a managedCluster ID pro clustery, které obsahují alespoň jednu 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"

Zobrazit seznam všech konfigurací fluxu, které jsou ve stavu nedodržování předpisů

Vrátí ID fluxConfiguration konfigurací, které se nedaří synchronizovat prostředky v clusteru.

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"

Další kroky

  • Přečtěte si další informace o dotazovacím jazyce.
  • Přečtěte si další informace o tom, jak prozkoumat prostředky.
  • Podívejte se na ukázky úvodních dotazů jazyka.
  • Podívejte se na ukázky pokročilých jazykových dotazů.