Azure Webjobs - Deploy and manage them from your Node App

Have you ever wanted to manage your Webjobs directly from your Node app without having to browse the Azure portal?
You can also define if they would be triggered or continuous and also set the CRON expression for the triggered one.

Folder structure for your webjobs

There is a specific folder structure you should follow so that Azure can pick up your Javascript files and show them in the Webjobs settings.


Create your run.js file in the above structure and push your changes. Refresh your Webjobs in Azure portal and you should be able to see it. If not, refresh again. :grimacing:


Add the CRON expression

Sweet. We now have a triggered webjob but we haven’t scheduled any CRON expression for it yet. We just need to add a settings.job file in our webjob folder.

  "schedule": "0 */15 * * * *"

The six fields of a CRON expression are:

{second} {minute} {hour} {day} {month} {day-of-week}

The above CRON expression will run the webjob every 15 minutes. Check this link for some CRON examples.

After adding the settings.job you should be able to see your CRON expression appear under the SCHEDULE column.


Continuous Webjob

Great, we have added a triggered webjob and set up how often it will run. You can follow the same process to add a continuous webjob. The difference between the two is that the continuous one will run only once its created. If you want it to run endlessly you have to handle that inside your code.

So the full folder structure for our two webjobs would be:

   |    │   
   |    └───demo-webjob
   |         │
   |         └─run.js

And the final result in Azure portal would be:


Folder structure on GitHub:

Azure Webjobs documentation:

Cron examples:

Written on March 24, 2018

Subscribe to the Newsletter

I occasionaly publish a blog post, subscribe if you want to get notified when I publish one :)

    I respect your privacy and there will be no spam. Unsubscribe at any time.

    Powered By ConvertKit