Creating WebJobs in Microsoft Azure

Zoe Sands, 24 June 2019

When working in CRM and other database systems we sometimes find that we need to automate pieces of work that cannot be handled within our system. This could be things like synchronizing data between two systems or sending daily notifications to users about work that is with them. In an On-Premise CRM environment, you would probably use a Windows Service hosted on a Server. For online clients trying to move away from hosting their own hardware we need to find a different solution. In the past this could have been a hosted virtual machine, however Azure is coming up with new ways for us to achieve our business tasks with more ease. WebJobs can be used to run these types of tasks. Typically, we find ourselves moving from Windows Services to Azure WebJobs as they are easier to configure, and the resources are managed for you by Microsoft.

To create and write your WebJob you can use any console application or create an Azure WebJob application.

There are two types of WebJobs -Triggered and Continuous. A triggered WebJob is run on a schedule defined using a CRON expression. Working with Dynamics CRM these WebJobs could be used in place of a waiting workflow, where you would like to send an email on a delayed schedule. A waiting workflow will become a drain on your Asynchronous services and cause your system to run slow. By removing these workflows, you could improve user experience in your CRM. If you need help generating CRON expressions, there are plenty of generators available to get you started.

A continuous WebJob does not run according to any schedule - once it finishes running it runs again. Continuous WebJobs should be used when you want something to always happen, or when you do not want any delay between your actions and the WebJobs task. For example, a system that sends and receives txt messages in your CRM.

Both types of Web Jobs are hosted in an Azure App Service. You can find the WebJobs section of your App Service under the Settings section. When creating them you need to have a ZIP of your logic files ready to upload into Azure. The following screenshots show the required detail for a Triggered WebJob and a Continuous WebJob.

image

image

The Name, Type and Scale/Schedule is up to you. The upload files will be all the dll files required in the console application you will have written to run as your WebJob.

I hope this will help you decide if you need an Azure WebJob when you are developing your systems.