Skip to content

Commit 8f7f0be

Browse files
committed
Arc SQL | ARG query for unhealthy extensions|
1 parent 49e7e83 commit 8f7f0be

3 files changed

Lines changed: 81 additions & 1 deletion

File tree

docs/sql-server/azure-arc/troubleshoot-deployment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.date: 02/01/2023
77
ms.topic: troubleshooting-general
88
---
99

10-
# Troubleshoot Azure extension for SQL Server
10+
# Troubleshoot Azure extension for SQL Server deployment
1111

1212
[!INCLUDE [sqlserver](../../includes/applies-to-version/sqlserver.md)]
1313

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
title: "Troubleshoot extension"
3+
description: "Describes how to troubleshoot SQL Server enabled by Azure Arc extension."
4+
author: MikeRayMSFT
5+
ms.author: mikeray
6+
ms.date: 06/03/2024
7+
ms.topic: troubleshooting-general
8+
---
9+
10+
# Troubleshoot Azure extension for SQL Server
11+
12+
[!INCLUDE [sqlserver](../../includes/applies-to-version/sqlserver.md)]
13+
14+
This article provides two examples that return a list of servers with unhealthy extensions.
15+
16+
## Identify unhealthy extensions
17+
18+
This query returns instances of SQL Server on servers with extensions installed, but not healthy. The dates are hard-coded into the query. It returns resources where the extension status is unhealthy, or the extension last upload time isn't in May 2024 (`2024/05`) or June 2024 (`2024/06`). Replace those dates for your resources.
19+
20+
```kusto
21+
resources
22+
| where type == "microsoft.hybridcompute/machines/extensions"
23+
| where properties.type in ("WindowsAgent.SqlServer","LinuxAgent.SqlServer")
24+
| where properties.instanceView.status.message !contains "SQL Server Extension Agent: Healthy" or (properties.instanceView.status.message !contains "timestampUTC : 2024/05" and properties.instanceView.status.message !contains "timestampUTC : 2024/06") or properties.instanceView.status.message !contains "uploadStatus : OK"
25+
| project id, resourceGroup, subscriptionId, 
26+
    ExtensionHealth = iif(properties.instanceView.status.message !contains "SQL Server Extension Agent: Healthy", "Unhealthy", "Healthy"),
27+
    LastUpdloadTimestamp = iif(indexof(properties.instanceView.status.message,"timestampUTC : ") > 0, iif(properties.instanceView.status.message !contains "timestampUTC : 2024/06", substring(properties.instanceView.status.message,indexof(properties.instanceView.status.message,"timestampUTC : ") + 15, 10),"Recent"),"no timestamp"),
28+
    LastUploadStatus = iif(indexof(properties.instanceView.status.message,"uploadStatus : OK") > 0, "OK", "Unhealthy"),
29+
    Message = properties.instanceView.status.message
30+
```
31+
32+
To identify possible specific problems, review the value in the **Message** property from the query results.
33+
34+
#### Identify unhealthy extension (PowerShell)
35+
36+
This example runs in PowerShell. With PowerShell, you can run with dates that aren't hard coded. The example returns resource where the extension status is unhealthy, or the extension last upload time isn't in this month or the previous month.
37+
38+
```powershell
39+
# PowerShell script to execute an Azure Resource Graph query using Azure CLI
40+
# where the extension status is unhealthy or the extension last upload time isn't in this month or the previous month.
41+
42+
# Requires the Az.ResourceGraph PowerShell module
43+
44+
# Login to Azure if needed
45+
#az login
46+
47+
$currentYear = (Get-Date).Year
48+
$currentMonth = "{0:D2}" -f (Get-Date).Month
49+
$previousMonth = "{0:D2}" -f ((Get-Date).Month-1)
50+
$currentDay = "{0:D2}" -f (Get-Date).Day
51+
$currentYearMonth = "$currentYear/$currentMonth"
52+
$previousYearMonth = "$currentYear/$previousMonth"
53+
$currentDate = "$currentYear/$currentMonth/$currentDay"
54+
55+
# Define the Azure Resource Graph query
56+
$query = @"
57+
Resources
58+
| where type == 'microsoft.hybridcompute/machines/extensions'
59+
| where properties.type in ('WindowsAgent.SqlServer','LinuxAgent.SqlServer')
60+
| where properties.instanceView.status.message !contains 'SQL Server Extension Agent: Healthy'
61+
or (properties.instanceView.status.message !contains 'timestampUTC : $previousYearMonth'
62+
and properties.instanceView.status.message !contains 'timestampUTC : $currentYearMonth')
63+
or properties.instanceView.status.message !contains 'uploadStatus : OK'
64+
| project id, resourceGroup, subscriptionId,
65+
ExtensionHealth = iif(properties.instanceView.status.message !contains 'SQL Server Extension Agent: Healthy', 'Unhealthy', 'Healthy'),
66+
LastUpdloadTimestamp = iif(indexof(properties.instanceView.status.message,'timestampUTC : ') > 0, iif(properties.instanceView.status.message !contains 'timestampUTC : $currentYearMonth', substring(properties.instanceView.status.message,indexof(properties.instanceView.status.message,'timestampUTC : ') + 15, 10),'Recent'),'no timestamp'),
67+
LastUploadStatus = iif(indexof(properties.instanceView.status.message,'uploadStatus : OK') > 0, 'OK', 'Unhealthy'),
68+
Message = properties.instanceView.status.message
69+
"@
70+
71+
# Execute the Azure Resource Graph query
72+
$result = Search-AzGraph -Query $query
73+
74+
# Output the results
75+
$result | Format-Table -Property ExtensionHealth, LastUpdloadTimestamp, LastUploadStatus, Message
76+
```
77+
78+
To identify possible specific problems, review the value in the **Message** column from the results.

docs/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10447,6 +10447,8 @@ items:
1044710447
items:
1044810448
- name: Troubleshoot deployment
1044910449
href: sql-server/azure-arc/troubleshoot-deployment.md
10450+
- name: Troubleshoot extension
10451+
href: sql-server/azure-arc/troubleshoot-extension.md
1045010452
- name: Troubleshoot connectivity to DPS or telemetry endpoints
1045110453
href: sql-server/azure-arc/troubleshoot-telemetry-endpoint.md
1045210454
- name: Troubleshoot best practices assessment

0 commit comments

Comments
 (0)