简体   繁体   English

从角色入口点开始加载DataCache

[英]Load DataCache from Role Entry Point On Start

I want to access my windows Azure Data Cache from my Role Entry StartUp routine. 我想从我的角色条目启动例程访问Windows Azure数据缓存。 However I keep getting this error: 但是我不断收到此错误:

{"ErrorCode:SubStatus:Server collection cannot be empty."} {“ ErrorCode:SubStatus:Server集合不能为空。”}

However when I do the same from within my Controller class it loads the Data Cache fine and I can go ahead and do things with it. 但是,当我从Controller类中进行同样的操作时,它可以很好地加载数据缓存,并且我可以继续进行处理。

Is there anything special for the Role Entry class that I have to do to access the Data Cache prior to my application starting? 在我的应用程序启动之前,角色入口类有什么特别的东西可以访问数据缓存吗?

Or can't I access the Cache in the Role StartUp ? 还是无法在“角色启动”中访问缓存?

Cheers 干杯

Starting with Azure SDK 1.3, there is a major change - the Full IIS mode. 从Azure SDK 1.3开始,有一个重大更改-完全IIS模式。 Read this blog post to get full undertanding of full IIS and what is it. 阅读此博客文章,以充分了解完整的IIS及其含义。

In short - your RoleEntryPoint descendant (where your OnStart method is being executed) lives in whole another AppDomain (and process actually - WaIISHost.exe), while your actual web application just lives in IIS (w3wp.exe). 简而言之-您的RoleEntryPoint后代(在其中执行OnStart方法的位置)完全位于另一个AppDomain中(并且实际上在处理-WaIISHost.exe),而实际的Web应用程序仅位于IIS(w3wp.exe)中。 That's why there is no way to do something in OnStart() that would affect your web applicatin or that would be able to directly read your web.config. 这就是为什么无法在OnStart()中做一些会影响您的Web应用程序或直接读取您的web.config的事情的原因。

If you do read Azure Data Cache in OnStart to do some preload of data for the web application, just do in your Global.asax's Application_Start() event handler. 如果您确实读过OnStart中的Azure数据缓存来为Web应用程序做一些数据预加载,则只需在Global.asax的Application_Start()事件处理程序中进行即可。

If you need to read Azure Data Cache in OnStart for reason's specific to the RoleEntryPoint, you have to load the configuration from web.config. 如果由于特定于RoleEntryPoint的原因需要在OnStart中读取Azure数据缓存,则必须从web.config加载配置。 Web.config is placed in "./bin/web.config" relative to your AppRoot folder. Web.config相对于您的AppRoot文件夹位于“ ./bin/web.config”中。 (there are two copies of your application when you use WebRoles with full IIS - one lives in AppRoot and one lives in SitesRoot). (当您将WebRoles与完整的IIS一起使用时,应用程序有两个副本-一个位于AppRoot中,一个位于SitesRoot中)。

Hope this helps! 希望这可以帮助!

WebRole's OnStart probably does not use your web.config where you probably have specified server names and access keys for your AppFabric DataCache provider. WebRole的OnStart可能不使用您的web.config,因为您可能已经为AppFabric DataCache提供程序指定了服务器名称和访问密钥。

I would try manually instrumenting the server connection configuration. 我会尝试手动检测服务器连接配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM