4

I deployed a continuous WebJobs to my existing Azure WebApp using DevOps. It is up and running.

When I tried to stop the webJob in the Azure web frontend it did not work. So I used the stop Command of the Azure WebApp API.

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/continuouswebjobs/{webJobName}/stop?api-version=2016-08-01

Surprisingly this call returned a 404 error.

However, when I executed the Get Continuous WebJob Command it returns all infos about the webJob, which means that it could be found.

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/continuouswebjobs/{webJobName}?api-version=2016-08-01

I also tried using the Kudu API.

POST /api/continuouswebjobs/{job name}/stop

However, the stop command resulted in the same 404 response message whereas the get command resulted in a positive result that the WebJob is in State "Running".

GET /api/continuouswebjobs/{job name}

Is there any reason for this behavior? How is it possible to start/ stop the webJob using the above mentioned post requests.

Oliver Vogel
  • 1,988
  • 1
  • 20
  • 33

3 Answers3

4

As it turned out the way I was deploying was the root of the problem.

Daniels answer to this question helped me a lot.

Basically you need to create a Virtual Application within your WebApp and then deploy your WebJob to this application from within Azure Devops.

When done this way you are in a position to successfully start/ stop the continuous webjob with all of the above mentioned APIs.

Oliver Vogel
  • 1,988
  • 1
  • 20
  • 33
0

According to what I read here, the accepted answer's linked subject (worth reading!), and my own configuration problem that concerned only one project of our projects, I noticed that in our case, the webjob that causes the 404 error was not published with the same output directory, it was published with $(Build.ArtifactStagingDirectory)/My.Api/app_data/jobs/Continuous/MyWebjob instead of $(Build.ArtifactStagingDirectory)/My.Api/app_data/jobs/Continuous/

So in our case we don't use virtual applications.

barbara.post
  • 1,581
  • 16
  • 27
-1

What's your way to stop webjob in the front end?

And the API to stop a continuous webjob, you could try with this

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/continuouswebjobs/{webJobName}/stop?api-version=2016-08-01

Further more information, you could refer to this doc:Stop Continuous Web Job

George Chen
  • 13,703
  • 2
  • 11
  • 26
  • I also tried this command which resulted in the same 404 error; actually this is the exact link I posted in my question. In the frontend I tried to stop the webJob pressing the "stop" button, which of course was my first attempt – Oliver Vogel Sep 18 '19 at 11:25
  • If this doesn't work, pease try with this one.https://github.com/projectkudu/kudu/wiki/WebJobs-API#stop-a-continuous-job – George Chen Sep 18 '19 at 11:28
  • If you use Get Continuous Web Job, what's you webjob status? – George Chen Sep 18 '19 at 11:35
  • Status is "Running" – Oliver Vogel Sep 18 '19 at 11:36
  • Could you stop it in azure portal and there is a powershell method to stop webjob.https://learn.microsoft.com/en-us/powershell/module/servicemanagement/azure/stop-azurewebsitejob?view=azuresmps-4.0.0 – George Chen Sep 18 '19 at 11:43