How to Kill sessions running for last 5 minutes automatically in azure analysis services?

86 Views Asked by At

I have a requirement to kill the active sessions currently running on Azure Analysis Services which are consuming high QPU and are running for more than 5 minutes.

I came across below article : which does similar thing and it's a manual process but I need help in understanding how can I setup an automated process which can proactively identify and kill such connections.

https://learn.microsoft.com/en-us/analysis-services/instances/disconnect-users-and-sessions-on-analysis-services-server?view=asallproducts-allversions

Appreciate any leads.

1

There are 1 best solutions below

2
Jahnavi On

How to Kill sessions running for last 5 minutes automatically in azure analysis services?

To make it work automatically, you can use either PowerShell or log analytics Kql query which is detailed below.

Disconnect sessions MS Doc.

PowerShell:

$subscription = "xxx"
$resourceGroup = "xxxx"
$serverName = "asazure://eastus.asazure.windows.net/newsj"
$uri = "https://management.azure.com/subscriptions/$subscription/resourceGroups/$resourceGroup/providers/Microsoft.AnalysisServices/servers/$serverName/sessions/$sessionId/disconnect?api-version=2017-07-14"
Invoke-RestMethod -Uri $uri -Method Post -Headers @{Authorization = "Bearer $token"}

enter image description here

KQL: (Log analytics workspace)

Sample query for your requirement looks like below:

AzureMetrics
| where Resource == "newsj"
| where MetricName == "xxx"
| summarize startat = min(TimeGenerated), timespan = max(xxx) by resourceID