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
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.
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.
The six fields of a CRON expression are:
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
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:
And the final result in Azure portal would be:
Notes - Links
Folder structure on GitHub: https://github.com/vaskort/vaskort.github.io/tree/second-post/App_Data
Azure Webjobs documentation: https://docs.microsoft.com/en-us/azure/app-service/web-sites-create-web-jobs