Search code examples
azureazure-webjobs

Running a Scheduled Azure WebJob Manually


I have a scheduled WebJob in Azure that runs nightly. Occasionally, I find that I need to run this job during the day at arbitrary times.

I would like to be able to manually re-run the job when I feel like it. Is this possible? I can see in the portal that the scheduler is set to hit the URL:

https://XXX.scm.azurewebsites.net/api/triggeredjobs/YYY/run

using a POST. I have tried to hit this URL myself. If I do it as a GET, I get a 404, and if I try a POST then I get an authorisation failure:

401 - Unauthorized: Access is denied due to invalid credentials

I could probably construct the necessary headers or whatever to do the auth, but this feels like yak shaving.

This seems (to me) like a trivial use case, and one that surely there's a button for somewhere in the Azure portal or Kudo?


Solution

  • There is authentication required on the request (you should be happy about that :)) This post shows how to form the correct basic auth URL to invoke your job, and also explains how things work behind the scenes which may interest you.

    However, you can also run your job from the portal. If you right click in the portal on the job you want to run, you'll see a "Run" context menu item. Not very discoverable I know :(