Web jobs and worker roles are used to create and run background tasks.
Below are the differences between them –
Web job
|
Worker role
|
Can be configured to run either OnDemand or Continuous or Scheduled
|
Explicit code needs to be written to configure the run
|
Deployed on a shared VM
|
Has a dedicated VM
|
Cannot be remote desktop but Azure does provide tools with restricted ability to manage the folders required for the deployed web job.
|
Can be remote desktop when RDP is enabled.
|
Cheaper
|
Relatively expensive
|
Configuration is limited
|
Has all the set of configurations
|
Scalable from the Web App which is hosting it
|
Scalable
|
Simple to code, test & deploy
|
Relatively complex
|
It is recommended to use Worker role when there are process intense & high resource(s) utilization requirements else for light weight executions use Web jobs.
Web jobs
Web jobs are recommended for running lightweight background tasks which requires minimum configuration or customization and less turnaround time to develop & deploy.
Some of the acceptable file types for web jobs to configure as background tasks
· .cmd
· .bat
· .exe
· .ps1
Below are the scenarios where web jobs can be perfect fit
· Data archiving
· (Asynchronous) logging
· Polling
Worker roles
Worker roles are recommended for running heavy weight, process intense & high resource(s) utilization.
Worker Roles are hosted on a standalone virtual machine which offers more control to the operating environment.
Below are the scenarios where worker roles can be perfect fir
· Startup tasks – to prepare environment to suit requirements
· Import jobs
· Background tasks that need to be scaled independently.
· Sending notifications