Freigeben über


Problembehandlung bei der Azure-Erweiterung für SQL Server

Gilt für:SQL Server

Verwenden Sie Azure Resource Graph, um den Zustand der Azure-Erweiterung für SQL Server auf Ihren Azure Arc-fähigen Servern zu identifizieren. In diesem Artikel werden Abfragen veranschaulicht, die fehlerhafte Erweiterungen identifizieren.

Tipp

Wenn Sie damit noch nicht vertraut sind, sollten Sie sich über Azure Resource Graph informieren:

Ermitteln fehlerhafter Erweiterungen

Sie können ein Dashboard im Azure-Portal erstellen, um den Status für alle bereitgestellten Azure-Erweiterungen für SQL Server anzuzeigen.

Tipp

Erstellen Sie Ihr eigenes Dashboard mit dieser Datei aus dem GitHub-Repository „sql-server-samples“: Arc-fähige SQL Server-Datei Health.json.

Abfragen fehlerhafter Erweiterungen

Diese Abfrage gibt Instanzen von SQL Server auf Servern zurück, auf denen Erweiterungen installiert, aber nicht fehlerfrei sind.

resources
| where type == "microsoft.hybridcompute/machines/extensions" 
| where properties.type in ("WindowsAgent.SqlServer", "LinuxAgent.SqlServer") 
| extend targetMachineName = tolower(tostring(split(id, '/')[8])) // Extract the machine name from the extension's id
| join kind=leftouter (
    resources
    | where type == "microsoft.hybridcompute/machines"
    | project machineId = id, MachineName = name, subscriptionId, LowerMachineName = tolower(name), resourceGroup , MachineStatus= properties.status , MachineProvisioningStatus= properties.provisioningState, MachineErrors = properties.errorDetails //Project relevant machine health information.
) on $left.targetMachineName == $right.LowerMachineName and $left.resourceGroup == $right.resourceGroup and $left.subscriptionId == $right.subscriptionId // Join Based on MachineName in the id and the machine's name, the resource group, and the subscription. This join allows us to present the data of the machine as well as the extension in the final output.
| extend statusExpirationLengthRange = 3d // Change this value to change the acceptable range for the last time an extension should have reported its status.
| extend startDate = startofday(now() - statusExpirationLengthRange), endDate = startofday(now()) // Get the start and end position for the given range.
| extend extractedDateString = extract("timestampUTC : (\\d{4}\\W\\d{2}\\W\\d{2})", 1, tostring(properties.instanceView.status.message)) // Extracting the date string for the LastUploadTimestamp. Is empty if none is found.
| extend extractedDateStringYear = split(extractedDateString, '/')[0], extractedDateStringMonth = split(extractedDateString, '/')[1], extractedDateStringDay = split(extractedDateString, '/')[2] // Identifying each of the parts of the date that was extracted from the message.
| extend extractedDate = todatetime(strcat(extractedDateStringYear,"-",extractedDateStringMonth,"-",extractedDateStringDay,"T00:00:00Z")) // Converting to a datetime object and rewriting string into ISO format because todatetime() does not work using the previous format.
| extend isNotInDateRange = not(extractedDate >= startDate and extractedDate <= endDate) // Created bool which is true if the date we extracted from the message is not within the specified range. This bool will also be true if the date was not found in the message.
| where properties.instanceView.status.message !contains "SQL Server Extension Agent: Healthy" // Begin searching for unhealthy extensions using the following 1. Does extension report being healthy. 2. Is last upload within the given range. 3. Is the upload status in an OK state. 4. Is provisioning state not in a succeeded state.
    or isNotInDateRange
    or properties.instanceView.status.message !contains "uploadStatus : OK"
    or properties.provisioningState != "Succeeded"
    or MachineStatus != "Connected"
| extend FailureReasons = strcat( // Makes a String to list all the reason that this resource got flagged for
        iif(MachineStatus != "Connected",strcat("- Machine's status is ", MachineStatus," -"),"") ,
        iif(MachineErrors != "[]","- Machine reports errors -", ""),
        iif(properties.instanceView.status.message !contains "SQL Server Extension Agent: Healthy","- Extension reported unhealthy -",""), 
        iif(isNotInDateRange,"- Last upload outside acceptable range -",""),
        iif(properties.instanceView.status.message !contains "uploadStatus : OK","- Upload status is not reported OK -",""), 
        iif(properties.provisioningState != "Succeeded",strcat("- Extension provisiong state is ", properties.provisioningState," -"),"") 
    )
| extend RecommendedAction = //Attempt to Identify RootCause based on information gathered, and point customer to what they should investigate first.
    iif(MachineStatus == "Disconnected", "Machine is disconnected. Please reconnect the machine.",
        iif(MachineStatus == "Expired", "Machine cert is expired. Go to the machine on the Azure portal for more information on how to resolve this issue.",
            iif(MachineStatus != "Connected", strcat("Machine status is ", MachineStatus,". Investigate and resolve this issue."),
                iif(MachineProvisioningStatus != "Succeeded", strcat("Machine provisioning status is ", MachineProvisioningStatus, ". Investigate and resolve machine provisioning status"),
                    iff(MachineErrors != "[]", "Machine is reporting errors. Investigate and resolve machine errors",
                        iif(properties.provisioningState != "Succeeded", strcat("Extension provisioning status is ", properties.provisioningState,". Investigate and resolve extension provisioning state."),
                            iff(properties.instanceView.status.message !contains "SQL Server Extension Agent:" and properties.instanceView.status.message contains "SQL Server Extension Agent Deployer", "SQL Server extension employer ran. However, SQL Server extension seems to not be running. Verify that the extension is currently running.",
                                iff(properties.instanceView.status.message !contains "uploadStatus : OK" or isNotInDateRange or properties.instanceView.status.message !contains "SQL Server Extension Agent: Healthy", "Extension reported as unhealthy. View FailureReasons and LastExtensionStatusMessage for more information as to the cause of the failure.",
                                    "Unable to recommend actions. Please view FailureReasons."
                                )
                            )
                        )
                    )
                )
            )
        )
    )
| project ID = id, MachineName, ResourceGroup = resourceGroup, SubscriptionID = subscriptionId, Location = location, RecommendedAction, FailureReasons, LicenseType = properties.settings.LicenseType, 
    LastReportedExtensionHealth = iif(properties.instanceView.status.message !contains "SQL Server Extension Agent: Healthy", "Unhealthy", "Healthy"),
    LastExtensionUploadTimestamp = iif(indexof(properties.instanceView.status.message, "timestampUTC : ") > 0,
        substring(properties.instanceView.status.message, indexof(properties.instanceView.status.message, "timestampUTC : ") + 15, 10),
        "no timestamp"),
    LastExtensionUploadStatus = iif(indexof(properties.instanceView.status.message, "uploadStatus : OK") > 0, "OK", "Unhealthy"),
    ExtensionProvisioningState = properties.provisioningState,
    MachineStatus, MachineErrors, MachineProvisioningStatus,MachineId = machineId,
    LastExtensionStatusMessage = properties.instanceView.status.message

Um mögliche Probleme zu identifizieren, überprüfen Sie den Wert in der Spalte EmpfohleneAktion oder Fehlergründe. Die Spalte „RecommendedAction“ enthält mögliche erste Schritte zur Behebung des Problems oder Hinweise darauf, was zuerst überprüft werden sollte. In der Spalte „FailureReasons“ werden die Gründe aufgeführt, warum die Ressource als fehlerhaft eingestuft wurde. Überprüfen Sie schließlich LastExtensionStatusMessage, um die letzte gemeldete Nachricht vom Agent anzuzeigen.

Handbuch zur Problembehandlung

Empfohlene Maßnahme Aktionsdetails
Das Computerzertifikat ist abgelaufen.

Weitere Informationen zum Beheben dieses Problems finden Sie bei der Maschine im Azure-Portal.
Der Arc-fähige Computer muss neu in Arc integriert werden, da das Zertifikat, das für die Authentifizierung bei Azure verwendet wurde, abgelaufen ist. Der Arc-Computerstatus im Azure-Portal ist Abgelaufen. Deinstallieren Sie den Agent, indem Sie der Dokumentation hier folgen und sie dann erneut hier integrieren. Es ist nicht erforderlich, die Arc-fähigen SQL Server-Ressourcen im Portal zu löschen, wenn Sie das Onboarding erneut ausführen. Die SQL-Erweiterung wird automatisch erneut installiert, solange automatisches Onboarding aktiviert ist (Standardeinstellung).
Der Computer ist getrennt.

Verbinden Sie den Computer erneut.
Der Arc-Computer befindet sich in einer state = Disconnected. Dieser Zustand kann aus verschiedenen Gründen sein:

Der mit Arc verbundene Computer-Agent ist angehalten, deaktiviert oder stürzt ständig ab.

oder

Die Konnektivität wird zwischen dem Agent und Azure blockiert.

Überprüfen Sie den Status dieser mit Arc verbundenen Computerdienste/Daemons, um sicherzustellen, dass sie aktiviert sind und ausführen.

Überprüfen der Konnektivität.

Problembehandlung für den Agent mithilfe des ausführlichen Protokolls.
Als fehlerhaft gemeldete Erweiterung.

Anzeigen von FailureReasons und LastExtensionStatusMessage, um mehr Informationen über die Ursache des Fehlers zu erhalten.

Letzter Upload außerhalb zulässiger Bereiche (innerhalb der letzten drei Tage).
Überprüfen Sie die Spalte LastExtensionUploadTimestamp. Wenn es sich um Kein Zeitstempelhandelt, wurden niemals Bestands- oder Nutzungsdaten an Azure gemeldet. Problembehandlung bei der Konnektivität der SQL-Erweiterung zu Azure.

Wenn der letzte Upload außerhalb des zulässigen Bereichs liegt (in den letzten drei Tagen) und alles andere wie LastExtensionUploadStatus, ExtensionProvisioningStateund MachineStatusin Ordnung aussieht, ist es möglich, dass der Arc SQL-Erweiterungsdienst/Daemon gestoppt wurde. Ermitteln Sie, warum sie angehalten wird, und starten Sie es erneut. Überprüfen Sie die LastExtensionStatusMessage- auf andere Hinweise zum Problem.
Der Bereitstellungsstatus der Erweiterung lautet Fehlgeschlagen.

Untersuchen Sie den Bereitstellungsstatus der Erweiterung, und lösen Sie ihn auf.
Fehler bei der Erstinstallation der SQL-Erweiterung oder beim Update. Überprüfen Sie die Bereitstellungs- und Erweiterungsprotokolle.

Überprüfen Sie den Wert in der LastExtensionStatusMessage.
Uploadstatus wird nicht gemeldet OK Überprüfen Sie die Spalte LastExtensionMessage im Dashboard, und sehen Sie sich den Wert uploadStatus und den Wert uploadMessage (sofern vorhanden, je nach Version) an.

Der uploadStatus-Wert ist in der Regel ein HTTP-Fehlercode. Überprüfen Sie Problembehandlung von Fehlercodes.

Die uploadMessage könnte spezifischere Informationen enthalten. Allgemeine Fehlerbehebung der Arc SQL-Erweiterung für die Konnektivität.
Der Bereitstellungsstatus der Erweiterung lautet Aktualisieren.

oder

Der Bereitstellungsstatus der Erweiterung lautet Erstellen

oder

Der Bereitstellungsstatus der Erweiterung lautet Fehlgeschlagen

oder

Der Bereitstellungsstatus der Erweiterung lautet Löschen
Wenn eine bestimmte Erweiterung länger als 30 Minuten in einem dieser Status verbleibt, liegt wahrscheinlich ein Problem mit der Bereitstellung vor. Deinstallieren Sie die Erweiterung, und installieren Sie sie mit der CLI oder dem Portal erneut. Wenn das Problem weiterhin besteht, überprüfen Sie die Bereitstellungs- und Erweiterungsprotokolle .

Wenn die Löschung fehlschlägt, versuchen Sie, den Agent zu deinstallieren und die Arc-Computerressource im Portal bei Bedarf zu löschen und dann erneut bereitzustellen.

Deinstallieren Sie den Agent, indem Sie der Dokumentation hier folgen und sie dann erneut hier integrieren.

Ermitteln einer fehlerhaften Erweiterung (PowerShell)

Dieses Beispiel wird in PowerShell ausgeführt. Das Beispiel gibt dasselbe Ergebnis wie die vorherige Abfrage, aber über ein PowerShell-Skript zurück.

# PowerShell script to execute an Azure Resource Graph query using Azure CLI
# where the extension status is unhealthy or the extension last upload time isn't in this month or the previous month.

# Requires the Az.ResourceGraph PowerShell module

# Login to Azure if needed
#az login

# Define the Azure Resource Graph query
$query = @"
resources
| where type == "microsoft.hybridcompute/machines/extensions" 
| where properties.type in ("WindowsAgent.SqlServer", "LinuxAgent.SqlServer") 
| extend targetMachineName = tolower(tostring(split(id, '/')[8])) // Extract the machine name from the extension's id
| join kind=leftouter (
    resources
    | where type == "microsoft.hybridcompute/machines"
    | project machineId = id, MachineName = name, subscriptionId, LowerMachineName = tolower(name), resourceGroup , MachineStatus= properties.status , MachineProvisioningStatus= properties.provisioningState, MachineErrors = properties.errorDetails //Project relevant machine health information.
) on $left.targetMachineName == $right.LowerMachineName and $left.resourceGroup == $right.resourceGroup and $left.subscriptionId == $right.subscriptionId // Join Based on MachineName in the id and the machine's name, the resource group, and the subscription. This join allows us to present the data of the machine as well as the extension in the final output.
| extend statusExpirationLengthRange = 3d // Change this value to change the acceptable range for the last time an extension should have reported its status.
| extend startDate = startofday(now() - statusExpirationLengthRange), endDate = startofday(now()) // Get the start and end position for the given range.
| extend extractedDateString = extract("timestampUTC : (\\d{4}\\W\\d{2}\\W\\d{2})", 1, tostring(properties.instanceView.status.message)) // Extracting the date string for the LastUploadTimestamp. Is empty if none is found.
| extend extractedDateStringYear = split(extractedDateString, '/')[0], extractedDateStringMonth = split(extractedDateString, '/')[1], extractedDateStringDay = split(extractedDateString, '/')[2] // Identifying each of the parts of the date that was extracted from the message.
| extend extractedDate = todatetime(strcat(extractedDateStringYear,"-",extractedDateStringMonth,"-",extractedDateStringDay,"T00:00:00Z")) // Converting to a datetime object and rewriting string into ISO format because todatetime() does not work using the previous format.
| extend isNotInDateRange = not(extractedDate >= startDate and extractedDate <= endDate) // Created bool which is true if the date we extracted from the message is not within the specified range. This bool will also be true if the date was not found in the message.
| where properties.instanceView.status.message !contains "SQL Server Extension Agent: Healthy" // Begin searching for unhealthy extensions using the following 1. Does extension report being healthy. 2. Is last upload within the given range. 3. Is the upload status in an OK state. 4. Is provisioning state not in a succeeded state.
    or isNotInDateRange
    or properties.instanceView.status.message !contains "uploadStatus : OK"
    or properties.provisioningState != "Succeeded"
    or MachineStatus != "Connected"
| extend FailureReasons = strcat( // Makes a String to list all the reason that this resource got flagged for
        iif(MachineStatus != "Connected",strcat("- Machine's status is ", MachineStatus," -"),"") ,
        iif(MachineErrors != "[]","- Machine reports errors -", ""),
        iif(properties.instanceView.status.message !contains "SQL Server Extension Agent: Healthy","- Extension reported unhealthy -",""), 
        iif(isNotInDateRange,"- Last upload outside acceptable range -",""),
        iif(properties.instanceView.status.message !contains "uploadStatus : OK","- Upload status is not reported OK -",""), 
        iif(properties.provisioningState != "Succeeded",strcat("- Extension provisiong state is ", properties.provisioningState," -"),"") 
    )
| extend RecommendedAction = //Attempt to Identify RootCause based on information gathered, and point customer to what they should investigate first.
    iif(MachineStatus == "Disconnected", "Machine is disconnected. Please reconnect the machine.",
        iif(MachineStatus == "Expired", "Machine cert is expired. Go to the machine on the Azure portal for more information on how to resolve this issue.",
            iif(MachineStatus != "Connected", strcat("Machine status is ", MachineStatus,". Investigate and resolve this issue."),
                iif(MachineProvisioningStatus != "Succeeded", strcat("Machine provisioning status is ", MachineProvisioningStatus, ". Investigate and resolve machine provisioning status"),
                    iff(MachineErrors != "[]", "Machine is reporting errors. Investigate and resolve machine errors",
                        iif(properties.provisioningState != "Succeeded", strcat("Extension provisioning status is ", properties.provisioningState,". Investigate and resolve extension provisioning state."),
                            iff(properties.instanceView.status.message !contains "SQL Server Extension Agent:" and properties.instanceView.status.message contains "SQL Server Extension Agent Deployer", "SQL Server extension employer ran. However, SQL Server extension seems to not be running. Verify that the extension is currently running.",
                                iff(properties.instanceView.status.message !contains "uploadStatus : OK" or isNotInDateRange or properties.instanceView.status.message !contains "SQL Server Extension Agent: Healthy", "Extension reported as unhealthy. View FailureReasons and LastExtensionStatusMessage for more information as to the cause of the failure.",
                                    "Unable to recommend actions. Please view FailureReasons."
                                )
                            )
                        )
                    )
                )
            )
        )
    )
| project ID = id, MachineName, ResourceGroup = resourceGroup, SubscriptionID = subscriptionId, Location = location, RecommendedAction, FailureReasons, LicenseType = properties.settings.LicenseType, 
    LastReportedExtensionHealth = iif(properties.instanceView.status.message !contains "SQL Server Extension Agent: Healthy", "Unhealthy", "Healthy"),
    LastExtensionUploadTimestamp = iif(indexof(properties.instanceView.status.message, "timestampUTC : ") > 0,
        substring(properties.instanceView.status.message, indexof(properties.instanceView.status.message, "timestampUTC : ") + 15, 10),
        "no timestamp"),
    LastExtensionUploadStatus = iif(indexof(properties.instanceView.status.message, "uploadStatus : OK") > 0, "OK", "Unhealthy"),
    ExtensionProvisioningState = properties.provisioningState,
    MachineStatus, MachineErrors, MachineProvisioningStatus,MachineId = machineId,
    LastExtensionStatusMessage = properties.instanceView.status.message
"@

# Execute the Azure Resource Graph query
$result = Search-AzGraph -Query $query

# Output the results
$result | Format-Table -Property ExtensionHealth, LastUploadTimestamp, LastUploadStatus, Message

Um mögliche Probleme zu identifizieren, überprüfen Sie den Wert in der Spalte EmpfohleneAktion oder Fehlergründe. Die Spalte „RecommendedAction“ enthält mögliche erste Schritte zur Behebung des Problems oder Hinweise darauf, was zuerst überprüft werden sollte. In der Spalte „FailureReasons“ werden die Gründe aufgeführt, warum die Ressource als fehlerhaft eingestuft wurde. Überprüfen Sie schließlich LastExtensionStatusMessage, um die letzte gemeldete Nachricht vom Agent anzuzeigen.

Identifizieren fehlender Updates für Erweiterungen

Identifizieren Sie Erweiterungen ohne aktuelle Statusaktualisierungen. Diese Abfrage gibt eine Liste der Azure-Erweiterungen für SQL Server zurück, die nach der Anzahl der Tage seit der letzten Aktualisierung der Erweiterung ihren Status sortiert haben. Ein Wert von „-1“ gibt an, dass die Erweiterung abgestürzt ist und ein Callstack im Erweiterungsstatus vorhanden ist.

// Show the timestamp extracted
// If an extension has crashed (i.e. no heartbeat), fill timestamp with "1900/01/01, 00:00:00.000"
//
resources
| where type =~ 'microsoft.hybridcompute/machines/extensions'
| extend extensionStatus = parse_json(properties).instanceView.status.message
| extend timestampExtracted = extract(@"timestampUTC\s*:\s*(\d{4}/\d{2}/\d{2}, \d{2}:\d{2}:\d{2}\.\d{3})", 1, tostring(extensionStatus))
| extend timestampNullFilled = iff(isnull(timestampExtracted) or timestampExtracted == "", "1900/01/01, 00:00:00.000", timestampExtracted)
| extend timestampKustoFormattedString = strcat(replace(",", "", replace("/", "-", replace("/", "-", timestampNullFilled))), "Z")
| extend agentHeartbeatUtcTimestamp = todatetime(timestampKustoFormattedString)
| extend agentHeartbeatLagInDays = datetime_diff('day', now(), agentHeartbeatUtcTimestamp)
| project id, extensionStatus, agentHeartbeatUtcTimestamp, agentHeartbeatLagInDays
| limit 100
| order by ['agentHeartbeatLagInDays'] asc

Diese Abfrage gibt die Anzahl der Erweiterungen zurück, die nach der Anzahl der Tage gruppiert sind, seit die Erweiterung ihren Status zuletzt aktualisiert hat. Ein Wert von „-1“ gibt an, dass die Erweiterung abgestürzt ist und ein Callstack im Erweiterungsstatus vorhanden ist.

// Aggregate by timestamp
//
// -1: Crashed extension with no heartbeat, we got a stacktrace instead
//  0: Healthy
// >1: Stale/Offline
//
resources
| where type =~ 'microsoft.hybridcompute/machines/extensions'
| extend extensionStatus = parse_json(properties).instanceView.status.message
| extend timestampExtracted = extract(@"timestampUTC\s*:\s*(\d{4}/\d{2}/\d{2}, \d{2}:\d{2}:\d{2}\.\d{3})", 1, tostring(extensionStatus))
| extend timestampNullFilled = iff(isnull(timestampExtracted) or timestampExtracted == "", "1900/01/01, 00:00:00.000", timestampExtracted)
| extend timestampKustoFormattedString = strcat(replace(",", "", replace("/", "-", replace("/", "-", timestampNullFilled))), "Z")
| extend agentHeartbeatUtcTimestamp = todatetime(timestampKustoFormattedString)
| extend agentHeartbeatLagInDays = iff(agentHeartbeatUtcTimestamp == todatetime("1900/01/01, 00:00:00.000Z"), -1, datetime_diff('day', now(), agentHeartbeatUtcTimestamp))
| summarize numExtensions = count() by agentHeartbeatLagInDays
| order by numExtensions desc