How to restart Azure App Service Instance
Asked Answered
R

3

35

I have an Azure App Service that contains 1 Web App with 1 slot. I have 2 instances assigned to the App Service. This week, the App Service shows about 60% CPU usage, and its usually about 10-15%. Upon further investigation, it looks like 1 of the two instances is maxed out. When opening up the Site Metrics per Instance, I can see that HTTP Response times are in the 1000s of milliseconds for one instance, and less than 200ms for the other. I have tried restarting the W3P process on the offending instance, but that doesn't seem to help. I have also tried scaling up to additional instances. The new instances look good, but when I scale back down, the fabric won't kill the offending instance.

How can I force the fabric controller to kill off a specific instance?

I found the AzureRestartRole powershell command here (https://msdn.microsoft.com/en-us/library/azure/dn495202.aspx), but my Azure Powershell Command Prompt doesn't seem to recognize the command, so I tried upgrading to Azure SDK 1.3 with the install-module command, but the 'AzureRestartRole' command isn't found.

Rhettrhetta answered 28/4, 2016 at 14:11 Comment(1)
I'm not sure if the Azure SDK 1.3 you are referring to, is the Azure Powershell 1.3 I'm thinking about. Regardless, try install the msi file from Azure githubDisordered
R
63

I recently encounter a similar issue (one bad instance always read null from ConfigurationManager.AppSettings while the other instance was fine). I found that restarting a particular instance of a Azure App service (web app) is do-able from the Azure portal. :D

Updated Aug 16th, 2019:

The short version is that if you go in the portal for your web app under Diagnose and Solve Problems, search for Advanced Application Restart and you will get an option that allows you to pick just the instance you want.

Hope that helps.

Reinsure answered 15/8, 2017 at 1:34 Comment(10)
is this something I can do in code from the instance itself? (eg. commit suicide on a certain condition)Olivia
"Advanced Application Restart is not supported for sites hosted in Free, Shared, or Dynamic App Service plans."...Tedi
@JasonGoemaat, thanks for pointing to the broken link. I have removed it. The information is still update to date though.Reinsure
@OlivierVaillancourt +1 from me, thanks for the heads up. Works well.Gillispie
Regarding "suicide on a certain condition", setting up an AutoHeal on Diagnose & Solve can run a memory dump or profile trace based on CPU, response time, status codes, etc. and allows an automatic restart of the instance @RotemSlootzkyReciprocal
I'm running an S1 App Service Plan and don't see "Advanced Application Restart" under my web app's "Diagnose and Solve Problems" menu. Has it been moved somewhere else since this answer was last updated?Doralia
@jschmitter: When you have the "Diagnose and solve" tab open. There is search box on the type. Try typing "Restart" in there. You should have the choice there. ThanksReinsure
It saved my life!!! This sounds a big bug in Azure services.Clementclementas
How is it possible that they made it that hard to find the command in the portal to restart your app 🤦‍♂️Grenville
Using a Container App Service, I am able to restart instances via the "Health Check" > "Instances" menu.Voltz
T
3

the commandlet you mentioned is not supposed to be used with the Azure App Service, but with the Azure Cloud Services and role model, so you do not need it here. Azure SDK 1.3 is very old as well, today the latest is 2.9.

Next, try to use Auto-Healing feature - it is difficult to understand why your web app is so resources consuming, especially if you tried to restart the W3WP (did you kill it in the Process Explorer of the dashboard?), so built-in feature can be helpful.

And you can find the webapp id and execute PowerShell, for example, Stop and Start it. If that will not help, i would suggest to re-create the instance.

Truthfunction answered 28/4, 2016 at 19:32 Comment(1)
Can that be done from bash? Or do we really have to learn PowerShell to list app instances and restart one?Sandiesandifer
C
3

Did some research regarding this thread. Looks like Azure APIs could solve the issue also.

Reference : https://learn.microsoft.com/en-us/rest/api/appservice/appserviceplans/rebootworker

Hope this helps !

Convocation answered 14/1, 2020 at 13:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.