Risolvere i problemi relativi all'estensione Azure per SQL Server
Si applica a:SQL Server
Usare Azure Resource Graph per identificare lo stato dell'estensione di Azure per SQL Server nei server abilitati per Azure Arc. Questo articolo illustra le query che identificano le estensioni non integre.
Suggerimento
Se non si ha già familiarità, vedere Azure Resource Graph:
Identificare le estensioni non integre
È possibile creare un dashboard nel portale di Azure per visualizzare l'integrità per tutte le estensioni di Azure distribuite per SQL Server.
Suggerimento
Crea il tuo dashboard con questo file dal repository GitHub sql-server-samples: Arc-enabled SQL Server Health.json.
Interrogare le estensioni malfunzionanti
Questa query restituisce istanze di SQL Server su server con estensioni installate, ma non integre.
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
Per identificare i possibili problemi, esaminare il valore nella colonna AzioneConsigliata o nella colonna MotiviDiGuasto. La colonna RecommendedAction fornisce i primi passaggi possibili per risolvere il problema o indizi su cosa controllare per primo. La colonna FailureReasons elenca i motivi per cui la risorsa è stata considerata non in buono stato. Infine, controllare LastExtensionStatusMessage per visualizzare l'ultimo messaggio segnalato dall'agente.
Guida alla risoluzione dei problemi
Azione consigliata | Dettagli azione |
---|---|
Il certificato della macchina è scaduto. Accedere alla macchina sul portale di Azure per ulteriori informazioni su come risolvere questo problema. |
Il computer abilitato per Arc deve essere rionboardato su Arc perché il certificato usato per l'autenticazione su Azure è scaduto. Lo stato del computer Arc è Scaduto nel portale di Azure. Disinstallare l'agente seguendo la documentazione qui e quindi eseguire di nuovo l'onboarding qui. Non è necessario eliminare le risorse di SQL Server abilitate per Arc nel portale se si esegue di nuovo l'onboarding. L'estensione SQL viene installata di nuovo automaticamente finché l'auto-onboarding di è abilitato (impostazione predefinita). |
Il computer è disconnesso. Riconnettere il computer. |
La macchina Arc si trova in un state = Disconnected . Questo stato potrebbe essere per vari motivi:L'agente della macchina connessa Arc è fermo, disabilitato o si blocca costantemente. o La connettività viene bloccata tra l'agente e Azure. Controllare lo stato dei servizi/daemon della macchina connessa ad Arc per assicurarsi che siano abilitati ed in esecuzione. Controllare la connettività. Risolvi i problemi dell'agente usando il log dettagliato. |
Estensione segnalata come non sana. Visualizzare FailureReasons e LastExtensionStatusMessage per altre informazioni sulla causa dell'errore. Ultimo caricamento esterno all'intervallo accettabile (negli ultimi tre giorni). |
Controllare la colonna LastExtensionUploadTimestamp. Se è Nessun timestamp, non ha mai segnalato dati di inventario o utilizzo in Azure.
Risoluzione dei problemi di connettività dall'estensione SQL ad Azure. Se l'ultimo caricamento non rientra nell'intervallo accettabile (negli ultimi tre giorni) e tutto il resto ha un aspetto corretto, ad esempio LastExtensionUploadStatus, ExtensionProvisioningStatee MachineStatus, è possibile che il servizio o il daemon dell'estensione ARC SQL venga arrestato. Scoprire perché è bloccato e riavviarlo. Controllare LastExtensionStatusMessage per eventuali altri indizi sul problema. |
Lo stato del provisioning dell'estensione è Non riuscito. Analizzare e risolvere lo stato di approvvigionamento dell'estensione. |
L'installazione iniziale dell'estensione SQL o l'aggiornamento non è riuscito.
Controllare i registri del deployer e dell'estensione. Controllare il valore nel LastExtensionStatusMessage. |
Lo stato di caricamento non è segnalato OK | Controllare la colonna LastExtensionMessage nel dashboard e osservare il valore uploadStatus e il valore uploadMessage (se presente, a seconda della versione). Il valore uploadStatus è in genere un codice di errore HTTP. Esamina e risolvi i problemi relativi ai codici di errore. Il uploadMessage potrebbe avere informazioni più specifiche. La risoluzione dei problemi di connettività dell'estensione Arc SQL generale. |
Lo stato del provisioning dell'estensione è aggiornamento o Lo stato di provisioning dell'estensione è Creazione di o Lo stato del provisioning dell'estensione è Non riuscito o Lo stato di provisioning dell'estensione è Eliminazione |
Se una determinata estensione rimane in uno di questi stati per più di 30 minuti, è probabile che vi sia un problema di provisioning. Disinstallare l'estensione e reinstallarla usando l'interfaccia della riga di comando o il portale. Se il problema persiste, controllare i log di distribuzione e di estensione. Se l'eliminazione non riesce, provare a disinstallare l'agente e, se necessario, eliminare la risorsa computer Arc nel portale, quindi distribuirla nuovamente. Disinstallare l'agente seguendo la documentazione qui e quindi eseguire di nuovo l'onboarding qui. |
Identificare l'estensione non integra (PowerShell)
Questo esempio viene eseguito in PowerShell. L'esempio restituisce lo stesso risultato della query precedente, ma tramite uno script di PowerShell.
# 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
Per identificare i possibili problemi, esaminare il valore nella colonna AzioneConsigliata o nella colonna MotiviDiGuasto. La colonna RecommendedAction fornisce i primi passaggi possibili per risolvere il problema o indizi su cosa controllare per primo. La colonna FailureReasons elenca i motivi per cui la risorsa è stata considerata non in buono stato. Infine, controllare LastExtensionStatusMessage per visualizzare l'ultimo messaggio segnalato dall'agente.
Identificare gli aggiornamenti mancanti delle estensioni
Identificare le estensioni senza aggiornamenti di stato recenti. Questa query restituisce un elenco di estensioni di Azure per SQL Server ordinate in base al numero di giorni dall'ultimo aggiornamento dello stato dell'estensione. Il valore '-1' indica che l'estensione si è arrestata in modo anomalo ed è presente uno stack di chiamate nello stato dell'estensione.
// 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
Questa query restituisce un conteggio delle estensioni raggruppate in base al numero di giorni dall'ultimo aggiornamento dello stato dell'estensione. Il valore '-1' indica che l'estensione si è arrestata in modo anomalo ed è presente uno stack di chiamate nello stato dell'estensione.
// 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