Deploying a scheduled webjob to Azure Webapp without Visual Studio - azure

I am having a hard time piecing together the documentation on Azure webjobs, so that I can deploy a scheduled WebJob to my WebApp without using Visual Studio. In my case the code is on GitHub and I want the deployment to be fully inititated by the webhook to Azure.
The documentation mentions that I can drop .exe into: \App_Data\jobs\continuous\webjob1 of my WebApp. I have created a post-build script that does that, which works fine. It's discovered and displayed in the Azure manager. But I can't make i scheduled.

Take a look at the following post to easily add a schedule to your WebJob.
Note that the path you are deploying the WebJob to \App_Data\jobs\continuous\webjob1 is actually for a continuous WebJob, you need a triggered WebJob that would go in the triggered directory \App_Data\jobs\triggered\webjob1.
Then you just add the settings.job file with the schedule property in the form of a cron expression (with 6 fields).
For example - {"schedule": "* 0 * * * *"} (once an hour at 1:00, 2:00, 3:00, ...).
Note that it requires your site to be "Always On".
Another option is to use Azure Scheduler service which you can configure from the current Azure Portal.

Related

Azure WebJobs not listing in Azure Kudo Portal

I'm trying to edit my configuration app.config from the Azure WebJob. I currently have 2 web jobs that configured to run as on-demand (Cron Scheduled)
My Jobs are working perfectly fine. But When I try to view the source code of my web jobs through Kudo Command
https://xxxxx.scm.azurewebsites.net/DebugConsole
I'm not able to see any jobs for the trigger. In fact, there is no folder called triggered
but when I tried to https://xx.scm.azurewebsites.net/azurejobs/#/jobs I can able to see my Jobs there.
How to find the source code of my WebJobs?
The default location for WebJobs is under d:\home\site\wwwroot\App_Data\jobs. Did you look there?

HOWTO update schedule of webjob in Azure

I've added some webjobs to an appjob. The webjobs are deplayed from VS together with a new version of the webapp.
TO schedule the jobs I've added a settings.job file to the webjob rootfolder.
If I look in Azure the webjobs are scheduled correctly.
But how to change that schedule from Azure ? The only way to change that schedule now seem to be to change the settings.job file and redeploy from VS.
UPDATE:
given that KUDU does not always work and that the procedure to change the schedule is not really fit for a non-tech user. I started looking at using azure scheduler. But cannot find out how to get it working.
From the webapp|webjob configuration I took the webhookurl, usr, pwd.
Created a new schedule using this webhookurl and credentials (basic auth)
But I get this error:
No route registered for '/api/triggeredwebjobs/<webjobname>/run'
Any suggestions?
how to change settings.job schedule.
You could put the settings.job file at the root of WebJob directory and modify it, then redeploy your WebJob project.
You could leverage kudu, and navigate to D:\home\site\wwwroot\app_data\jobs\triggered\<job-name>, then modify the settings.job.
Moreover, you could use the WebJobs API for creating/updating the schedule for a triggered job, and it would automatically create/update the settings.job file for you.
PUT https://{webdeploy-username}:{password}#{your-webapp-name}.scm.azurewebsites.net/api/triggeredwebjobs/{webjob-name}/settings
Body: {"schedule": "*/30 * * * * *"}
I have checked my WebJob log on kudu, it would take some time for the modified schedule to take effort.
I started looking at using azure scheduler. But cannot find out how to get it working.
No route registered for '/api/triggeredwebjobs//run'
For Azure Scheduler, you could refer to David Ebbo's blog here. Based on your error, I assumed that your Http method is wrong, you should use POST. Here is my test, you could refer to it:
For those who struggle with the same issue :
Best solution turned out to be to use Azure's Scheduler Job Collections.
The tricky part was finding out how to set this up.
Action settings:
- https
- copy the uri you find in the properties page of the webjob to call, it is called 'webhook'
- copy the credentials from the same place
You can also access Kudu (Advanced Tools) at https://yoursite.scm.azurewebsites.net, and modify the settings.job file directly via the Console.
I would recommend you redeploy though so that you have the right schedules in your version control at all times. Otherwise you might publish and then realize you have the old schedules again.

Azure WebJob running in WebApp without a JobSchedule/JobCollection - deploy with template

Right. So this article: https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/ mentions that you can "You can run programs or scripts in WebJobs in your App Service web app in three ways: on demand, continuously, or on a schedule. There is no additional cost to use WebJobs."
Which is great, the free-alternative is a Scheduler Job Collection
with a job, but you're limited to running it every hour. So being able to run the webjob as part of the webapp, and on a higher frequency is what we need.
However, I'm really struggling to find any way of automating this process. Using the Azure portal to add a web job works fine - but the "automation script" generation tool doesn't generate a json file which includes anything about the webjob - so we'd always have to manually create it.
There are examples of custom templates for automating the creation of webjobs - but they all create said webjob as part of a Scheduler Job Collection, where we are limited to the hourly execution.
To summarise: I'm looking for a way of automating the creation of a webjob, linked to a web-app (such that it doesn't incur extra costs).
Any help would be much appreciated.
WebJobs are deployed by folder convention (as described here), so deploying a WebJob is no different from deploying a Web App. It's simply a matter of getting the files in the right place.
Specifically, triggered WebJobs (manual or scheduled) go under site\wwwroot\app_data\jobs\triggered\{job name} and continuous WebJobs go under site\wwwroot\app_data\jobs\continuous\{job name}.

How to deploy a webjob through CI in VSO with vNext

I'm trying to deploy a scheduled webjob through CI and vNext tasks in VSO.
I followed the steps in the following tutorial to deploy a webjob along with a web app ("Enable automatic deployment with a web project"):
https://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-deploy-webjobs/
I succeeded partially: the webjob gets deployed along with the web application. However, it is marked as On Demand instead of Scheduled (or whatever the proper status is). I can run the webjob manually and it runs just fine. I checked the files webjob-publish-settings.json (in the webjob) and webjobs-list.json (in the web app) and they seem to be alright, judging from the tutorial.
Am I missing anything? Thank you.
You can use the cron expression to create the webjob scheduler if your app is running in Basic or High mode. Refer to this link for details: Create a scheduled WebJob using a CRON expression
Otherwise, you need to enable continues delivery of Azure Webjobs.
More reference: Deploy your WebJobs projects with your Azure website using continuous delivery

Modify scheduling on Azure WebJob

Like many others I am enthusiastic about the lightweight WebJobs that can so easily be added to Azure Websites.
But I assumed one of the advantages with WebJobs was to easily modify the scheduling. When I tried I was surprised that there seems to be no way to do that. A deployed WebJob seems to be stuck with the initial scheduling.
Do I need to deploy new WebJobs just to modify the scheduling?
To change the schedule, or to Modify the CRON value just use the App Service Editor to modify the WWWROOT/App_Data/jobs/triggered/YOUR_WEBJOB_NAME/settings.job file;
By the time of writing, App Service Editor is still in preview but it
will work.
In the settings.job file amend the schedule in CRON value and will be reflected in the App's Web Job Dashboard.
The App Service Editor is available in App Service > Development Tools
App Service Editor (Preview)
I finally found it.
Scheduled WebJobs turn up under Scheduler in the main bar.
The Save button is not visible until you actually make a change.

Resources