A Microsoft Azure Web Role is a Windows Server Compatible Virtual Machine (VM) with IIS enabled, along with scaffolding code that provides a launch point for your own code to run within the VM.
Web Roles and Worker Roles form the basis of the Azure Cloud Services PaaS offering, removing the need for developers to manage the platform on which their applications will run.
The primary difference between a Web Role and Worker Role is the enabling of IIS. Both Web Roles and Worker Roles may run the same code, though it's often useful to split code between different roles for scaling purposes.
Within Visual Studio, you'll also see a slightly different role template, but the 4 primary events/overrides are available in both:
- OnStart()
- Run()
- Stopping()
- OnStop()
Further: If apps need to be installed (or registry changes are needed), and those tasks need elevated privileges, there's the ability to run startup tasks, which execute prior to OnStart().
In either roles you can choose the type of operating system running by modifying the service configuration file (.cscfg). Possible options are:
- osFamily 1: equivalent of Windows Server 2008 SP2 x64
- osFamily 2: equivalent of Windows Server 2008 R2
- osFamily 3: equivalent of Windows Server 2012
- osFamily 4: equivalent of Windows Server 2012 R2
You can read more about service configuration schema here.