2

I'm planning to do some light background processing in Azure. I already have a webrole running and would like to use the same role in order I don't have to use (and pay!) a dedicated worker role for that.

I have read I can simply override Run() in the WebRole class, which derives from RoleEntryPoint, and implement my 'poor man's scheduling' there. It should periodically get messages from the queue and process them.

Now my question is: Does the WebRole run in its own process or thread, or more important, what happens with WebRole when the app pool/app domain gets recycled?

David Makogon
  • 69,407
  • 21
  • 141
  • 189
kay.herzam
  • 3,053
  • 3
  • 26
  • 37

2 Answers2

2

If you are running with Full IIS mode (available 1.3 SDK onwards), the RoleEntryPoint and IIS are in different processes. You will know you are using Full IIS mode if you have a <Sites> element in your ServiceDefinition.

IIS actually runs your website in w3wp.exe (just like you would expect normally) as it's own appPool. The RoleEntryPoint code is launched and parented by a completely different process, so there is no tie between them (crashing one will not impact the other for instance).

dunnry
  • 6,858
  • 1
  • 20
  • 20
  • 2
    Well, that last parenthetical clause isn't quite true. If your RoleEntryPoint crashes, Windows Azure will restart the role instance, which will in turn end up restarting your IIS website. – user94559 Nov 14 '11 at 23:50
  • @smarx - good point. I was thinking more the opposite case - website crashes. – dunnry Nov 15 '11 at 01:38
  • 1
    In addition, for the question "what happens with WebRole when the app pool/app domain gets recycled" - nothing happens to the WebRole when AppPool is recycled. – astaykov Nov 15 '11 at 05:50
  • Thanks everybody for explaining! – kay.herzam Nov 15 '11 at 06:11
2

To add to @dunnry's answer; what is also interesting, is that run is called on a copy of your assembly in this folder:

e:\approot\bin

Whereas IIS is pointing to another copy of your application in this folder:

e:\siteroot\0
Richard Astbury
  • 2,323
  • 18
  • 28