Does Azure Webjob stop when Azure App Service is stopped - azure

In our current setup there are 2 slots for an Azure App service, the question that I have is, when the slot is stopped would it also shut down the webjob that is deployed on that slot or would the web job continue to run?

It is possible to run an Azure WebJob even when the Azure App Service Web App is not running.
Though you can force the WebJob not to run or stop when the Web App is running using WEBJOBS_STOPPED setting in your Web App's "Application Settings"
Take a look at this article about this subject for more details:
https://blogs.msdn.microsoft.com/benjaminperkins/2017/03/01/failed-to-run-webjob/
The following picture shows a running WebJob when the web app is not running:

https://github.com/projectkudu/kudu/wiki/Full-stopping-a-Web-App
I have actually deleted some running jobs, but even though my jobs were shown as deleted in the UI, they are silently running and consuming the memory. I observed this from availability and Performance > Memory Analysis dashboard under Memory Drill Down > Memory Usage (App) > Physical Memory Usage section. Shocked to see the jobs still running after they are deleted. Luckily this solution helped me kill all the processes.

Related

HandlerChanged to (httpPlatformHandlerMain) issue in Azure

I was running a web app service and all of a sudden I see a degraded performance in the response time. I did not do code changes but I get the followin warning:
We analyzed 15 slow request(s) and identified module(s) consuming most of the time are - HandlerChanged to (httpPlatformHandlerMain)(95.83%)
I did not explicitly change any configuration on Azure so thats why I am suprised to see such degraded service.
I redeployed the same code and restarted the webapp
There might be several reasons for degraded performance in your Azure Web App Service, such as increased traffic, changes in modifying infrastructure.
Follow the below steps to troubleshoot Azure Web App Performance issue.
Check the resource utilization: Kindly check the Azure Web App utilization such as CPU, Memory, and Disk Space.
If your Web App utilization is high, you may need to scale up your App Service plan, Like below.
Check the Web Application logs: Kindly check if any error messages in the logs that could indicate the cause of the issue. You can check the logs in the Azure portal by navigating to below options.
Azure Portal > Select your App Service > Log stream
Monitor your app performance: Monitor the performance of your Azure Web App by sending Apps Logs to Log Analytics workspace to get a better understanding of the App performance degradation issues,
Azure Portal > Select your App Service > Diagnostic settings > Add diagnostic setting
You can check for recent changes in your application., such as changes to the code & configuration, to see if they are causing any performance issues in your application.
Restart the App Service: Sometimes you can resolve the Azure App performance issues by restarting the application.
Azure Portal > App Service > Select your application > Overview > Restart
For more information refer : Troubleshoot slow app performance issues in Azure App Service

Will Azure App service restart restarts the web jobs too?

I am just wondering whether Azure web jobs are restarted when I restart my app service?
When you hit the restart in azure portal, both the web app and web jobs get restarted. You can take a look at the official doc here:
Note that when you hit Restart, both the main and SCM sites get restarted.
The SCM site is where Kudu runs, including WebJobs.
You should also keep in mind that when you click Stop in the azure portal, only the main site is stopped, while the SCM site(where web jobs running) keeps running.
Yes, if we restart the webapp, the webjob would also get restarted.
If you go to Kudu console of the webapp (webappname.scm.azurewebsites.net) and click on Process Explorer you will notice that the webjob is running under the w3wp.exe_scm which is the w3wp process for the kudu site. Also, the site is running under w3wp.exe.
If you restart the webapp, process ID for both the w3wp.exe would change.

App Service Plan with high CPU without load

We have an App Service Plan in Azure (PremiumV2: 1 Medium) with 14 App Services setup, but they are all stopped.
So without any load (that I know of), our CPU sometimes spikes to 100%. Is this normal? How can I find out what is causing the spikes? I'm guessing it isn't one of the App Services, since they are all stopped.
Generally, we click stop botton in the panel of Azure portal to stop an app service, but it only stop the main site you deployed under wwwroot, not the SCM site where Kudu & WebJob runs.
There is an offical document of Kudu wiki Full stopping a Web App which may explain your current case. When you deployed some WebJobs running in your App Services, they will not be stoped by clicking the stop operation in Azure portal. And it seems to be some continous WebJob running which cause the CPU & Memory consuming.
If you want to stop all of them thoroughly, please follow the wiki above to know how to do. Hope it helps.

New and old WebJob versions both running following a deployment

I have a continuous WebJob deployed via the Kudu API to /api/continuouswebjobs/{job name} as outlined here. The App Service I'm deploying to has just a single instance running.
On occasion it's looking like the previous version of a WebJob is not removed following a deployment and it runs concurrently with the new version. This can continue to occur and I've seen up to nine processes running concurrently.
Application names redacted but they are identical for each process:
Stopping the WebJob via the Azure Portal causes the process under w3wp (scm) to stop but not the other "detached" processes.
The company I am working with has seen this with different WebJobs across different App Service Plans. We've also confirmed this outside of Azure with our own logs, where we see multiple versions of the same application running.
Update 1
I couldn't reproduce the issue using David's steps from the comments. I did however revert back to our old release process which stopped and started the App Service pre and post release. I've since realised this wasn't needed as WebJobs continue to run under scm even when the App Service is stopped.
However...
Post-deploy while the WebJob is at state "Starting":
Post-deploy while the WebJob is at state "Running":
I've created a dummy site named "dummy739047" on the same App Service Plan as per the Kudu docs if a further investigation is needed.

Stopping an Azure Service does *not* stop the WebJob's continuously running behind it

I have an Azure WebJob that is running on a pretty simple App Service Standard: 1 Small (plan).
Now, there was a problem with my WebJob (which has 5 functions running) - I wanted to stop 4 of the 5 running functions. I couldn't see how, so I thought I'd just stop the entire WebJob instead.
So I ended up just stopping the App Service.
Great, that was stopped, but the WebJob was still running and I didn't notice that until a few hours later.
I later noticed that the WebJob blade has its own Start/Stop button.
I thought the WebJobs were tied directly to the App Service.
What is the connection between the two? How does one affect that other?
As far as I know, the web app and web jobs has different process in the azure.
You could find the Process explorer in the web portal as below:
So the stop in the web app will just closed the app's process(6584 as the image shows).
It will not stop the webjob's process(4648).
These two processes has no connection.
If you want to stop both web app process and webjobs process, I suggest you could try to use this way Full stopping a Web App.

Resources