Worker Role is any role in Azure that runs applications and services level tasks, which generally do not require IIS. In Worker Roles, IIS is not installed by default. They are mainly used to perform supporting background processes along with Web Roles and do tasks such as automatically compressing uploaded images, run scripts when something changes in database, get new messages from queue and process and more.
Worker Roles on the other hand are meant for heavier tasks which require a higher level of customization. These are best suited for executing jobs which have dependencies on the Windows registry, environment variables or similar Windows infrastructure services.
A key advantage of using Worker Roles is the ability to execute start up tasks. Startup tasks can be used to prepare the execution environment to suit specific requirements. Worker Roles are hosted on a standalone virtual machine which offers more control to the operating environment. Because of this, a Worker Role may be a good choice where there is a requirement to remote in to the host virtual machine. However, making any change to the application image deployed on a worker role using remote desktop is not advisable as the change will not persist after role recycling. The deployment of a Worker Role takes more time compared to a Web Job.
Following are the scenarios where a Worker Role may be a better fit than a Web Job:
-
Locked down environment which requires strong security boundaries to be set up before executing the task. Banks and other financial institutions usually have such requirements.
-
Legacy workloads using COM components which require registration during start up.
-
Completely decoupled task layer where the background tasks need to be scaled independently
About Author
Brijesh Kumar
Database Developer
I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL
Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall
and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com