Automating Server Restart for Socket Alert in Microsoft Insights

sindhu sneha 150 Reputation points
2023-08-10T07:53:50.6133333+00:00

In my organization they have configured a scheduled query rule in Microsoft Insights that triggers an socket alert when the socket of my web app is unexpectedly closed. The rule currently sends alert emails to a designated group of email IDs, and the subsequent process requires manual intervention to restart the server. Is there a way to automate this process, allowing the server to be automatically restarted upon receiving the socket alert? I'm open to suggestions on how to achieve this automation, and I appreciate any insights or guidance you can provide. Thank you!

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,560 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,634 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ryan Hill 30,026 Reputation points Microsoft Employee
    2023-08-16T02:20:32.18+00:00

    Hi @sindhu sneha

    You weren't clear on if your web app is running on PaaS or IaaS; but you can leverage Azure Automation to run a PowerShell runbook execute the appropriate Az module to restart your web app. For instance, if you needed to restart your app service, the runbook would contain something like

    # Stop the App Service
    Stop-AzWebApp -ResourceGroupName "myresourcegroup" -Name "myappservice"
    
    # Start the App Service
    Start-AzWebApp -ResourceGroupName "myresourcegroup" -Name "myappservice"
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.