Nuta
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować się zalogować lub zmienić katalog.
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować zmienić katalogi.
Azure Resource Graph to usługa platformy Azure, która umożliwia wykonywanie zapytań na dużą skalę, co ułatwia efektywne zarządzanie środowiskiem. Zapytania są tworzone przy użyciu języka zapytań Kusto (KQL). Aby uzyskać więcej informacji, zobacz Omówienie języka zapytań usługi Azure Resource Graph.
Ta strona zawiera listę przykładowych zapytań usługi Azure Resource Graph dla usługi Azure Arc. Te zapytania można uruchamiać za pomocą programu Azure PowerShell lub interfejsu wiersza polecenia platformy Azure albo w witrynie Azure Portal przy użyciu Eksploratora usługi Resource Graph. Możesz modyfikować zapytania zgodnie z twoimi potrzebami.
Wskazówka
Za pomocą rozwiązania Microsoft Copilot na platformie Azure możesz tworzyć zapytania usługi Azure Resource Graph przy użyciu języka naturalnego. Aby uzyskać więcej informacji, zobacz Uzyskiwanie informacji o zasobach przy użyciu rozwiązania Microsoft Copilot na platformie Azure.
Ogólne przykładowe zapytania dotyczące Arc
Pobierz obsługiwane typy zasobów dla niestandardowych lokalizacji z obsługą Azure Arc
Zawiera listę włączonych typów zasobów dla lokalizacji niestandardowych z obsługą Azure Arc.
ExtendedLocationResources
| where type == 'microsoft.extendedlocation/customlocations/enabledresourcetypes'
az graph query -q "ExtendedLocationResources | where type == 'microsoft.extendedlocation/customlocations/enabledresourcetypes'"
Wyświetlanie listy lokalizacji niestandardowych z obsługą usługi Azure Arc z włączonym programem VMware lub programem SCVMM
Zawiera listę wszystkich niestandardowych lokalizacji obsługiwanych przez Azure Arc, które mają włączone typy zasobów VMware lub SCVMM.
Resources
| where type =~ 'microsoft.extendedlocation/customlocations' and properties.provisioningState =~ 'succeeded'
| extend clusterExtensionIds=properties.clusterExtensionIds
| mvexpand clusterExtensionIds
| extend clusterExtensionId = tolower(clusterExtensionIds)
| join kind=leftouter(
ExtendedLocationResources
| where type =~ 'microsoft.extendedlocation/customLocations/enabledResourcetypes'
| project clusterExtensionId = tolower(properties.clusterExtensionId), extensionType = tolower(properties.extensionType)
| where extensionType in~ ('microsoft.scvmm','microsoft.vmware')
) on clusterExtensionId
| where extensionType in~ ('microsoft.scvmm','microsoft.vmware')
| summarize virtualMachineKindsEnabled=make_set(extensionType) by id,name,location
| sort by name asc
az graph query -q "Resources | where type =~ 'microsoft.extendedlocation/customlocations' and properties.provisioningState =~ 'succeeded' | extend clusterExtensionIds=properties.clusterExtensionIds | mvexpand clusterExtensionIds | extend clusterExtensionId = tolower(clusterExtensionIds) | join kind=leftouter( ExtendedLocationResources | where type =~ 'microsoft.extendedlocation/customLocations/enabledResourcetypes' | project clusterExtensionId = tolower(properties.clusterExtensionId), extensionType = tolower(properties.extensionType) | where extensionType in~ ('microsoft.scvmm','microsoft.vmware') ) on clusterExtensionId | where extensionType in~ ('microsoft.scvmm','microsoft.vmware') | summarize virtualMachineKindsEnabled=make_set(extensionType) by id,name,location | sort by name asc"
Przykładowe zapytania dotyczące serwerów z obsługą usługi Arc
Pobieranie liczby i wartości procentowych serwerów z obsługą usługi Arc według domeny
To zapytanie podsumowuje domainName właściwość na serwerach z obsługą usługi Azure Arc i używa obliczeń z parametrem bin w celu utworzenia Pct kolumny dla procentu serwerów z obsługą usługi Arc na domenę.
Resources
| where type == 'microsoft.hybridcompute/machines'
| project domain=tostring(properties.domainName)
| summarize Domains=make_list(domain), TotalMachineCount=sum(1)
| mvexpand EachDomain = Domains
| summarize PerDomainMachineCount = count() by tostring(EachDomain), TotalMachineCount
| extend Pct = 100 * bin(todouble(PerDomainMachineCount) / todouble(TotalMachineCount), 0.001)
az graph query -q "Resources | where type == 'microsoft.hybridcompute/machines' | project domain=tostring(properties.domainName) | summarize Domains=make_list(domain), TotalMachineCount=sum(1) | mvexpand EachDomain = Domains | summarize PerDomainMachineCount = count() by tostring(EachDomain), TotalMachineCount | extend Pct = 100 * bin(todouble(PerDomainMachineCount) / todouble(TotalMachineCount), 0.001)"
Wyświetlanie listy wszystkich rozszerzeń zainstalowanych na serwerze z obsługą usługi Azure Arc
Najpierw to zapytanie używa project typu zasobu maszyny hybrydowej, aby uzyskać identyfikator w wielkiej litery (toupper()), uzyskać nazwę komputera i system operacyjny uruchomiony na maszynie. Uzyskanie identyfikatora zasobu w wielkiej litery to dobry sposób przygotowania do join innej właściwości. Następnie zapytanie używa join z kind jako leftouter, aby pobrać rozszerzenia, dopasowując wielką literę substring identyfikatora rozszerzenia. Część identyfikatora przed /extensions/<ExtensionName> jest tym samym formatem co identyfikator maszyny hybrydowej, dlatego używamy tej właściwości dla elementu join.
summarize jest następnie używany wraz z make_list na nazwie rozszerzenia maszyny wirtualnej, aby połączyć nazwy każdego rozszerzenia, gdzie identyfikator, OSName i ComputerName są takie same, w jednym atrybucie tablicy. Na koniec porządkujemy według nazwy OSName zapisanej małymi literami za pomocą asc. Domyślnie order by jest ustawione na malejące.
Resources
| where type == 'microsoft.hybridcompute/machines'
| project
id,
JoinID = toupper(id),
ComputerName = tostring(properties.osProfile.computerName),
OSName = tostring(properties.osName)
| join kind=leftouter(
Resources
| where type == 'microsoft.hybridcompute/machines/extensions'
| project
MachineId = toupper(substring(id, 0, indexof(id, '/extensions'))),
ExtensionName = name
) on $left.JoinID == $right.MachineId
| summarize Extensions = make_list(ExtensionName) by id, ComputerName, OSName
| order by tolower(OSName) asc
az graph query -q "Resources | where type == 'microsoft.hybridcompute/machines' | project id, JoinID = toupper(id), ComputerName = tostring(properties.osProfile.computerName), OSName = tostring(properties.osName) | join kind=leftouter( Resources | where type == 'microsoft.hybridcompute/machines/extensions' | project MachineId = toupper(substring(id, 0, indexof(id, '/extensions'))), ExtensionName = name ) on \$left.JoinID == \$right.MachineId | summarize Extensions = make_list(ExtensionName) by id, ComputerName, OSName | order by tolower(OSName) asc"
Wyświetlanie listy serwerów z obsługą usługi Arc, na których nie jest uruchomiona najnowsza wersja agenta wydanego
To zapytanie zwraca wszystkie serwery z obsługą usługi Arc z nieaktualną wersją agenta połączonej maszyny. Agenci ze stanem Wygasły są wykluczeni z wyników. Zapytanie używa leftouterjoin do zestawienia rekomendacji doradcy dotyczących wszelkich agentów maszyn połączonych, które zostały zidentyfikowane jako nieaktualne, oraz maszyn komputerów hybrydowych, aby wyfiltrować dowolnego agenta, który nie komunikował się z platformą Azure przez dłuższy okres czasu.
AdvisorResources
| where type == 'microsoft.advisor/recommendations'
| where properties.category == 'HighAvailability'
| where properties.shortDescription.solution == 'Upgrade to the latest version of the Azure Connected Machine agent'
| project
id,
JoinId = toupper(properties.resourceMetadata.resourceId),
machineName = tostring(properties.impactedValue),
agentVersion = tostring(properties.extendedProperties.installedVersion),
expectedVersion = tostring(properties.extendedProperties.latestVersion)
| join kind=leftouter(
Resources
| where type == 'microsoft.hybridcompute/machines'
| project
machineId = toupper(id),
status = tostring (properties.status)
) on $left.JoinId == $right.machineId
| where status != 'Expired'
| summarize by id, machineName, agentVersion, expectedVersion
| order by tolower(machineName) asc
az graph query -q "AdvisorResources | where type == 'microsoft.advisor/recommendations' | where properties.category == 'HighAvailability' | where properties.shortDescription.solution == 'Upgrade to the latest version of the Azure Connected Machine agent' | project id, JoinId = toupper(properties.resourceMetadata.resourceId), machineName = tostring(properties.impactedValue), agentVersion = tostring(properties.extendedProperties.installedVersion), expectedVersion = tostring(properties.extendedProperties.latestVersion) | join kind=leftouter( Resources | where type == 'microsoft.hybridcompute/machines' | project machineId = toupper(id), status = tostring (properties.status) ) on \$left.JoinId == \$right.machineId | where status != 'Expired' | summarize by id, machineName, agentVersion, expectedVersion | order by tolower(machineName) asc"
Wyświetlanie listy serwerów z obsługą usługi Arc z zainstalowanym programem SQL Server, PostgreSQL lub programem MySQL
To zapytanie zwraca wszystkie serwery z obsługą usługi Arc z zainstalowanym programem SQL Server, PostgreSQL lub MySQL.
resources
| where type =~ 'microsoft.hybridcompute/machines'
| extend machineId = tolower(tostring(id)), datacenter = iif(isnull(tags.Datacenter), '', tags.Datacenter), status = tostring(properties.status)
| extend mssqlinstalled = coalesce(tobool(properties.detectedProperties.mssqldiscovered),false)
| extend pgsqlinstalled = coalesce(tobool(properties.detectedProperties.pgsqldiscovered),false)
| extend mysqlinstalled = coalesce(tobool(properties.detectedProperties.mysqldiscovered),false)
| extend osSku = properties.osSku, osName = properties.osName, osVersion = properties.osVersion
| extend coreCount = tostring(properties.detectedProperties.logicalCoreCount), totalPhysicalMemoryinGB = tostring(properties.detectedProperties.totalPhysicalMemoryInGigabytes)
| extend operatingSystem = iif(isnotnull(osSku), osSku, osName)
| where mssqlinstalled or mysqlinstalled or pgsqlinstalled
| project id ,name, type, resourceGroup, subscriptionId, location, kind, osVersion, status, osSku,coreCount,totalPhysicalMemoryinGB,tags, mssqlinstalled, mysqlinstalled, pgsqlinstalled
| sort by (tolower(tostring(name))) asc
az graph query -q "resources | where type =~ 'microsoft.hybridcompute/machines' | extend machineId = tolower(tostring(id)), datacenter = iif(isnull(tags.Datacenter), '', tags.Datacenter), status = tostring(properties.status) | extend mssqlinstalled = coalesce(tobool(properties.detectedProperties.mssqldiscovered),false) | extend pgsqlinstalled = coalesce(tobool(properties.detectedProperties.pgsqldiscovered),false) | extend mysqlinstalled = coalesce(tobool(properties.detectedProperties.mysqldiscovered),false) | extend osSku = properties.osSku, osName = properties.osName, osVersion = properties.osVersion | extend coreCount = tostring(properties.detectedProperties.logicalCoreCount), totalPhysicalMemoryinGB = tostring(properties.detectedProperties.totalPhysicalMemoryInGigabytes) | extend operatingSystem = iif(isnotnull(osSku), osSku, osName) | where mssqlinstalled or mysqlinstalled or pgsqlinstalled | project id ,name, type, resourceGroup, subscriptionId, location, kind, osVersion, status, osSku,coreCount,totalPhysicalMemoryinGB,tags, mssqlinstalled, mysqlinstalled, pgsqlinstalled | sort by (tolower(tostring(name))) asc"
Przykładowe zapytania Kubernetes obsługiwane przez Arc
Wyświetlanie listy wszystkich zasobów platformy Kubernetes z włączoną usługą Azure Arc
Zwraca listę każdego klastra Kubernetes z obsługą usługi Azure Arc i odpowiednie metadane dla każdego klastra.
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'"
Wyświetlanie listy wszystkich klastrów Kubernetes z włączoną usługą Azure Arc za pomocą rozszerzenia usługi Azure Monitor
Zwraca identyfikator połączonego klastra dla każdego klastra Kubernetes z włączoną usługą Azure Arc, który ma zainstalowane rozszerzenie usługi 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"
Wyświetlanie listy wszystkich klastrów Kubernetes z włączoną usługą Azure Arc bez rozszerzenia usługi Azure Monitor
Zwraca identyfikator połączonego klastra dla każdego klastra Kubernetes z włączoną usługą Azure Arc, który nie ma rozszerzenia usługi Azure Monitor.
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"
Wyświetlanie listy wszystkich klastrów zawierających konfigurację platformy Flux
Zwraca identyfikatory connectedCluster i managedCluster dla klastrów zawierających co najmniej jeden 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"
Wyświetlanie listy wszystkich konfiguracji flux w stanie niezgodnym
Zwraca identyfikatory konfiguracji, które zawodzą w synchronizacji zasobów w klastrze.
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"