Working with the settings.job file of an Azure Web Job

Jordan Hohepa, 27 September 2018

When creating an Azure Web Job, you have the option to create a ‘continuous’ web job or a ‘triggered’ web job. With triggered jobs you can decide whether this should only be triggered manually or be triggered on a schedule.

image

The screenshot above shows a web job which is set to be triggered every 30 minutes using the CRON expression * */30 * * * *. From the Azure Portal (the screen above), you won’t be able to change the CRON expression, so you won’t be able to update when the job will be triggered from here.

image

To change the trigger schedule, you can instead update the settings.job file which is in the same directory. By navigating to Advanced Tools and selecting Go as shown in the screenshot above, you’ll be taken to the Kudu page. From here, selecting Debug console in the nav bar and CMD, you’ll be shown the directories of the current web app. This is only one method to get here, you can use other methods outside of Azure like FTP if you’d like.

image


After navigating to the directory my triggered app is in, I can see the settings.job file. The screenshot below shows the CRON expression which is the scheduled time the web job would be triggered. If I change this and hit save, the job would be updated to trigger on the new schedule, for example * */15 * * * * would trigger it every 15 minutes instead.

image

An interesting way we can use this file is by using multiple schedules to run multiple branches of the same web job. For example, the screenshot below shows two web jobs, one triggered every 15 minutes and one triggered every 30 minutes. Let’s assume these two web jobs are exactly the same. We could branch the logic in these web jobs into two paths, one for running every 15 minutes and one for running every 30 minutes. To decide which path you’d like the job to take, all you’d need to do is read the schedule from the settings.job file, for example if the file contains ‘* */15 * * * *’ run the “Every 15 minutes” logic. This allows you to re-use the same web job but with multiple triggers and paths.

image