Przykładowe zapytania usługi Azure Resource Graph dla usługi Azure Service Health

Ta strona jest kolekcją przykładowych zapytań usługi Azure Resource Graph dla usługi Azure Service Health. Aby uzyskać pełną listę przykładów usługi Azure Resource Graph, zobacz Przykłady usługi Resource Graph według kategorii i przykładów usługi Resource Graph według tabeli.

Azure Service Health

Wpływ subskrypcji zdarzeń usługi Active Service Health

Zwraca wszystkie aktywne zdarzenia usługi Service Health — w tym problemy z usługą, planowaną konserwację, porady dotyczące kondycji i biuletyny zabezpieczeń — pogrupowane według typu zdarzenia i uwzględniając liczbę subskrypcji, których dotyczy problem.

ServiceHealthResources
| where type =~ 'Microsoft.ResourceHealth/events'
| extend eventType = tostring(properties.EventType), status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = properties.ImpactMitigationTime
| where eventType == 'ServiceIssue' and status == 'Active'
| summarize count(subscriptionId) by name
az graph query -q "ServiceHealthResources | where type =~ 'Microsoft.ResourceHealth/events' | extend eventType = tostring(properties.EventType), status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = properties.ImpactMitigationTime | where eventType == 'ServiceIssue' and status == 'Active' | summarize count(subscriptionId) by name"

Wszystkie aktywne zdarzenia doradcze dotyczące kondycji

Zwraca wszystkie aktywne zdarzenia usługi Service Health w ramach wszystkich subskrypcji, do których użytkownik ma dostęp.

ServiceHealthResources
| where type =~ 'Microsoft.ResourceHealth/events'
| extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = todatetime(tolong(properties.ImpactMitigationTime))
| where eventType == 'HealthAdvisory' and impactMitigationTime > now()
az graph query -q "ServiceHealthResources | where type =~ 'Microsoft.ResourceHealth/events' | extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = todatetime(tolong(properties.ImpactMitigationTime)) | where eventType == 'HealthAdvisory' and impactMitigationTime > now()"

Wszystkie aktywne zdarzenia planowanej konserwacji

Zwraca wszystkie aktywne zdarzenia usługi Service Health planowanej konserwacji we wszystkich subskrypcjach, do których użytkownik ma dostęp.

ServiceHealthResources
| where type =~ 'Microsoft.ResourceHealth/events'
| extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = todatetime(tolong(properties.ImpactMitigationTime))
| where eventType == 'PlannedMaintenance' and impactMitigationTime > now()
az graph query -q "ServiceHealthResources | where type =~ 'Microsoft.ResourceHealth/events' | extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = todatetime(tolong(properties.ImpactMitigationTime)) | where eventType == 'PlannedMaintenance' and impactMitigationTime > now()"

Wszystkie aktywne zdarzenia usługi Service Health

Zwraca wszystkie aktywne zdarzenia usługi Service Health we wszystkich subskrypcjach, do których użytkownik ma dostęp, w tym problemy z usługą, planowana konserwacja, porady dotyczące kondycji i biuletyny zabezpieczeń.

ServiceHealthResources
| where type =~ 'Microsoft.ResourceHealth/events'
| extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = properties.ImpactMitigationTime
| where (eventType in ('HealthAdvisory', 'SecurityAdvisory', 'PlannedMaintenance') and impactMitigationTime > now()) or (eventType == 'ServiceIssue' and status == 'Active')
az graph query -q "ServiceHealthResources | where type =~ 'Microsoft.ResourceHealth/events' | extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = properties.ImpactMitigationTime | where (eventType in ('HealthAdvisory', 'SecurityAdvisory', 'PlannedMaintenance') and impactMitigationTime > now()) or (eventType == 'ServiceIssue' and status == 'Active')"

Wszystkie aktywne zdarzenia problemów z usługą

Zwraca wszystkie aktywne zdarzenia usługi Service Health (awaria) we wszystkich subskrypcjach, do których użytkownik ma dostęp.

ServiceHealthResources
| where type =~ 'Microsoft.ResourceHealth/events'
| extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = properties.ImpactMitigationTime
| where eventType == 'ServiceIssue' and status == 'Active'
az graph query -q "ServiceHealthResources | where type =~ 'Microsoft.ResourceHealth/events' | extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = properties.ImpactMitigationTime | where eventType == 'ServiceIssue' and status == 'Active'"

Potwierdzone zasoby, których dotyczy ten wpływ

Zwraca wszystkie zasoby, których dotyczy problem z usługą (awaria) zdarzenia usługi Service Health we wszystkich subskrypcjach, do których użytkownik ma dostęp.

ServiceHealthResources
| where type == "microsoft.resourcehealth/events/impactedresources"
| extend TrackingId = split(split(id, "/events/", 1)[0], "/impactedResources", 0)[0]
| extend p = parse_json(properties)
| project subscriptionId, TrackingId, resourceName= p.resourceName, resourceGroup=p.resourceGroup, resourceType=p.targetResourceType, details = p, id
az graph query -q "ServiceHealthResources | where type == 'microsoft.resourcehealth/events/impactedresources' | extend TrackingId = split(split(id, '/events/', 1)[0], '/impactedResources', 0)[0] | extend p = parse_json(properties) | project subscriptionId, TrackingId, resourceName= p.resourceName, resourceGroup=p.resourceGroup, resourceType=p.targetResourceType, details = p, id"

Potwierdzono, że zasoby, których dotyczy ten wpływ, zawierają więcej szczegółów

Zwraca wszystkie zasoby, których dotyczy problem z usługą (awaria) zdarzenia usługi Service Health we wszystkich subskrypcjach, do których użytkownik ma dostęp. To zapytanie zawiera również więcej szczegółów z resources tabeli.

servicehealthresources
| where type == "microsoft.resourcehealth/events/impactedresources"
| extend TrackingId = split(split(id, "/events/", 1)[0], "/impactedResources", 0)[0]
| extend p = parse_json(properties)
| project subscriptionId, TrackingId, targetResourceId= tostring(p.targetResourceId), details = p
| join kind=inner (
    resources
    )
    on $left.targetResourceId == $right.id
az graph query -q "ServiceHealthResources | where type == 'microsoft.resourcehealth/events/impactedresources' | extend TrackingId = split(split(id, '/events/', 1)[0], '/impactedResources', 0)[0] | extend p =  parse_json(properties) | project subscriptionId, TrackingId, targetResourceId = tostring(p.targetResourceId), details = p | join kind=inner (resources) on $left.targetResourceId == $right.id"

Kondycja zasobów

Liczba maszyn wirtualnych według stanu dostępności i identyfikatora subskrypcji

Zwraca liczbę maszyn wirtualnych (typ Microsoft.Compute/virtualMachines) zagregowanych według ich stanu dostępności w każdej subskrypcji.

HealthResources
| where type =~ 'microsoft.resourcehealth/availabilitystatuses'
| summarize count() by subscriptionId, AvailabilityState = tostring(properties.availabilityState)
az graph query -q "HealthResources | where type =~ 'microsoft.resourcehealth/availabilitystatuses' | summarize count() by subscriptionId, AvailabilityState = tostring(properties.availabilityState)"

Lista maszyn wirtualnych i skojarzonych stanów dostępności według identyfikatorów zasobów

Zwraca najnowszą listę maszyn wirtualnych (typ Microsoft.Compute/virtualMachines) zagregowanych według stanu dostępności. Zapytanie udostępnia również skojarzony identyfikator zasobu na properties.targetResourceIdpodstawie elementu w celu łatwego debugowania i ograniczania ryzyka. Stany dostępności mogą być jedną z czterech wartości: Dostępne, Niedostępne, Obniżone i Nieznane. Aby uzyskać więcej informacji na temat znaczenia poszczególnych stanów dostępności, zobacz Omówienie usługi Azure Resource Health.

HealthResources
| where type =~ 'microsoft.resourcehealth/availabilitystatuses'
| summarize by ResourceId = tolower(tostring(properties.targetResourceId)), AvailabilityState = tostring(properties.availabilityState)
az graph query -q "HealthResources | where type =~ 'microsoft.resourcehealth/availabilitystatuses' | summarize by ResourceId = tolower(tostring(properties.targetResourceId)), AvailabilityState = tostring(properties.availabilityState)"

Lista maszyn wirtualnych według stanu dostępności i stanu zasilania z identyfikatorami zasobów i grupami zasobów

Zwraca listę maszyn wirtualnych (typ Microsoft.Compute/virtualMachines) zagregowanych na ich stanie zasilania i stanu dostępności, aby zapewnić spójny stan kondycji maszyn wirtualnych. Zapytanie zawiera również szczegółowe informacje dotyczące grupy zasobów i identyfikatora zasobu skojarzonego z każdym wpisem w celu uzyskania szczegółowego wglądu w zasoby.

Resources
| where type =~ 'microsoft.compute/virtualmachines'
| project resourceGroup, Id = tolower(id), PowerState = tostring( properties.extended.instanceView.powerState.code)
| join kind=leftouter (
	HealthResources
	| where type =~ 'microsoft.resourcehealth/availabilitystatuses'
	| where tostring(properties.targetResourceType) =~ 'microsoft.compute/virtualmachines'
	| project targetResourceId = tolower(tostring(properties.targetResourceId)), AvailabilityState = tostring(properties.availabilityState))
	on $left.Id == $right.targetResourceId
| project-away targetResourceId
| where PowerState != 'PowerState/deallocated'
az graph query -q "Resources | where type =~ 'microsoft.compute/virtualmachines' | project resourceGroup, Id = tolower(id), PowerState = tostring( properties.extended.instanceView.powerState.code) | join kind=leftouter ( HealthResources | where type =~ 'microsoft.resourcehealth/availabilitystatuses' | where tostring(properties.targetResourceType) =~ 'microsoft.compute/virtualmachines' | project targetResourceId = tolower(tostring(properties.targetResourceId)), AvailabilityState = tostring(properties.availabilityState)) on \$left.Id == \$right.targetResourceId | project-away targetResourceId | where PowerState != 'PowerState/deallocated'"

Lista maszyn wirtualnych, które nie są dostępne według identyfikatorów zasobów

Zwraca najnowszą listę maszyn wirtualnych (typ Microsoft.Compute/virtualMachines) zagregowanych według ich stanu dostępności. Wypełniona lista wyróżnia tylko maszyny wirtualne, których stan dostępności nie jest "Dostępny", aby upewnić się, że znasz wszystkie stany, w których znajdują się maszyny wirtualne. Gdy wszystkie maszyny wirtualne są dostępne, możesz oczekiwać, że nie otrzymasz żadnych wyników.

HealthResources
| where type =~ 'microsoft.resourcehealth/availabilitystatuses'
| where tostring(properties.availabilityState) != 'Available'
| summarize by ResourceId = tolower(tostring(properties.targetResourceId)), AvailabilityState = tostring(properties.availabilityState)
az graph query -q "HealthResources | where type =~ 'microsoft.resourcehealth/availabilitystatuses' | where tostring(properties.availabilityState) != 'Available' | summarize by ResourceId = tolower(tostring(properties.targetResourceId)), AvailabilityState = tostring(properties.availabilityState)"

Następne kroki