在 asp.net MVC 上创建 Azure 存储表
我按照这篇博客文章创建一个天蓝色存储表: http://blogs.msdn。 com/jnak/archive/2008/10/28/walkthrough-simple-table-storage.aspx
它在 asp.net webform web_role 上运行良好。
我使用 asp.net mvc 作为 Web 角色重新创建了相同的项目,但它在应用程序启动时总是失败。 这一行:
StorageAccountInfo account = StorageAccountInfo.GetDefaultTableStorageAccountFromConfiguration();
似乎总是无法获取帐户共享密钥。
如果我将该行从全局 asax 应用程序启动移动到 default.aspx,它工作得很好。
This is the error call stack from event viewer
Exception information: Exception type: HttpException Exception message: No account key specified! Request information: Request URL: http://127.0.0.1:5100/do.__rd_runtime_init__?shutdownEvent=1B671B93FD-4153-4834-9D5D-595EFC6C19EE1D Request path: /do.__rd_runtime_init__ User host address: 127.0.0.1 User: Is authenticated: False Authentication Type: Thread account name: ***** Thread information: Thread ID: 6 Thread account name: ***** Is impersonating: False Stack trace: at System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) at System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) at System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) at System.Web.HttpApplicationFactory.GetPipelineApplicationInstance(IntPtr appContext, HttpContext context) at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)
I'm following this blog post to create an azure storage table:
http://blogs.msdn.com/jnak/archive/2008/10/28/walkthrough-simple-table-storage.aspx
It works fine on an asp.net webform web_role.
I've re-created the same project using asp.net mvc as the web role, and it's always failing on application start. this line:
StorageAccountInfo account = StorageAccountInfo.GetDefaultTableStorageAccountFromConfiguration();
seem to always fail getting the account shared key.
If I move the line from global asax application start to default.aspx, it works perfectly fine.
This is the error call stack from event viewer
Exception information: Exception type: HttpException Exception message: No account key specified! Request information: Request URL: http://127.0.0.1:5100/do.__rd_runtime_init__?shutdownEvent=1B671B93FD-4153-4834-9D5D-595EFC6C19EE1D Request path: /do.__rd_runtime_init__ User host address: 127.0.0.1 User: Is authenticated: False Authentication Type: Thread account name: ***** Thread information: Thread ID: 6 Thread account name: ***** Is impersonating: False Stack trace: at System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) at System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) at System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) at System.Web.HttpApplicationFactory.GetPipelineApplicationInstance(IntPtr appContext, HttpContext context) at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 http://msdn 中的“备注” .microsoft.com/en-us/library/microsoft.servicehosting.serviceruntime.rolemanager.aspx:
Check out the "remarks" at http://msdn.microsoft.com/en-us/library/microsoft.servicehosting.serviceruntime.rolemanager.aspx:
如果使用:
通常帐户信息在 Web.conf 文件中给出。
If you use:
Usually the account information is given in the Web.conf file.