2

Out of curiosity I opened my Azure web role project, navigated to the file that contained the RoleEntryPoint descendant class and completely removed that class definition. Then I packaged the role and deployed it in Azure - the role started without any error indication.

How could that possibly work?

sharptooth
  • 167,383
  • 100
  • 513
  • 979

2 Answers2

4

In addition to what DarwkwingDuck said, I will just mention that RoleEntryPoint Provides methods to run code when a role instance is initialized, run, and stopped.

If we continue to read through the RoleEntryPoint class documentation on MSDN we will also see the following:

Worker roles must extend the RoleEntryPoint class to add functionality to the role instances. Web roles can optionally extend the RoleEntryPoint class, or can use the ASP.NET lifecycle management methods to handle the start and stop sequences. For a VM role, Windows Services are used instead of the RoleEntryPoint class.

So, Web roles can optionally extend the RoleEntryPoint class.

astaykov
  • 30,768
  • 3
  • 70
  • 86
3

The RoleEntryPoint exists in your deployment regardless of whether or not you inherit from it. Notice that all the methods you have in that class override the base class implementations. Those base class implementations will execute instead if you don't inherit RoleEntryPoint.

This also makes it easier to bring legacy apps into Azure - just add an existing web app to a cloud project as a role and away you go.

DarkwingDuck
  • 2,686
  • 24
  • 29
  • How is that possible? RoleEntryPoint is abstract. – Aidan Ryan Feb 12 '13 at 22:08
  • @AidanRyan The abstract keyword is applied at the class level, not the method level. So while RoleEntryPoint must be inherited (because it can't be instantiated), its methods need not be overridden. – BobbyA Aug 28 '17 at 20:34
  • Abstract classes can't be instantiated, and the OP says the descendent class was completely deleted... So what exactly is being instantiated in this case? I have a feeling there is some infrastructure parallel and separate from RoleEntryPoint that is invoked in the Web role case... – Aidan Ryan Aug 29 '17 at 16:39