How does Azure web role happen to run without an entry point?

别来无恙 提交于 2020-01-05 03:05:44

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/9173101/how-does-azure-web-role-happen-to-run-without-an-entry-point

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!