2012-10-23 36 views
5

当我尝试将具有RavenDB的嵌入式实例的MVC4网站部署到新的Azure网站预览功能时,我收到Access denied消息。该网站在当地正常工作。在Azure网站上嵌入RavenDB - 访问被拒绝

这是我如何配置乌鸦:

//Initialize the RavenDB Data Store 
     Raven.Database.Server.NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8887); 

     var documentStore = new EmbeddableDocumentStore() 
     { 
      DataDirectory = "~\\App_Data", 
      UseEmbeddedHttpServer = true, 
      Configuration = { Port = 8887 } 
     }; 

     documentStore.Initialize(); 

这里是堆栈跟踪,当我浏览到该网站:

Access is denied 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Net.NetworkInformation.NetworkInformationException: Access is denied 

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 


[NetworkInformationException (0x5): Access is denied] 
    System.Net.NetworkInformation.SystemIPGlobalProperties.GetAllTcpConnections() +1570717 
    System.Net.NetworkInformation.SystemIPGlobalProperties.GetActiveTcpListeners() +74 
    Raven.Database.Util.PortUtil.FindPort() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Util\PortUtil.cs:110 
    Raven.Database.Util.PortUtil.GetPort(String portStr) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Util\PortUtil.cs:44 
    Raven.Database.Config.InMemoryRavenConfiguration.Initialize() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Config\InMemoryRavenConfiguration.cs:170 
    Raven.Database.Config.RavenConfiguration.LoadConfigurationAndInitialize(IEnumerable`1 values) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Config\RavenConfiguration.cs:28 
    Raven.Database.Config.RavenConfiguration..ctor() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Config\RavenConfiguration.cs:17 
    Raven.Client.Embedded.EmbeddableDocumentStore.get_Configuration() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Embedded\EmbeddableDocumentStore.cs:63 
    Raven.Client.Embedded.EmbeddableDocumentStore.set_DataDirectory(String value) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Embedded\EmbeddableDocumentStore.cs:90 
    Solarity.DesignSearch.Website.Bootstrapper.BuildUnityContainer() in c:\a\src\Solarity.DesignSearch\Solarity.DesignSearch.Website\Bootstrapper.cs:35 
    Solarity.DesignSearch.Website.Bootstrapper.Initialise() in c:\a\src\Solarity.DesignSearch\Solarity.DesignSearch.Website\Bootstrapper.cs:20 
    Solarity.DesignSearch.Website.MvcApplication.Application_Start() in c:\a\src\Solarity.DesignSearch\Solarity.DesignSearch.Website\Global.asax.cs:23 

[HttpException (0x80004005): Access is denied] 
    System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9859725 
    System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118 
    System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172 
    System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336 
    System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296 

[HttpException (0x80004005): Access is denied] 
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912 
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254 
+0

您是否注意到此线程? http://stackoverflow.com/questions/11529159/ravendb-on-azure-websites-access-denied –

+0

@MattJohnson - 您的评论是指云服务,而问题是关于网站的问题。如果上下文是Cloud Services,那么您应该是正确的,但是,Web站点允许用于托管Web应用程序的持久环境,而无需担心在回收Cloud Service时清除缓存磁盘 –

+0

@ SyntaxC4很高兴知道 - 谢谢! –

回答

3

我设法让它工作,虽然它不理想。你可能会注意到在我的原始文章中我设置了UseEmbeddedHttpServer = true。这样我可以浏览http:[MyUrl]:8081并获取RavendDB Management Studio,以便浏览我的数据。出于某种原因,RavenDB希望在设置此属性时执行相同类型的端口检查,因为它将端口设置设置为自动(端口= *)时的情况。

我相信RavenDB可能需要修复,以便在UseEmbeddedHttpServer为True时授予端口设置,并且还允许您在创建时设置EmbeddedDocumentStore的Configuration属性。

但是与此同时,只需通过指定一个端口,就可以真正让您的MVC4网站在Azure网站上与EmbeddedDocumentStore一起使用。另外,确实必须使用AppSettings配置,而不是在创建时设置EmbeddedDocumentStore的Configuration属性(就像我上面所做的那样)。这篇文章(stackoverflow.com/questions/11529159/)展示了如何去做。

不幸的是,我仍然没有找到运行EmbeddedHttpServer的方法,所以我可以使用Raven Management Studio。如果我弄清楚如何,我会在这里发布解决方案。

+0

您是否找到sln?或者你仍然无法使用天蓝色网站的工作室? – Larsi

+0

仍然无法使用天蓝色网站的工作室,但根据ayende在下面的线程,这是设计。 https://groups.google.com/forum/?fromgroups=#!searchin/ravendb/Azure$20网站/ravendb/HW463DU27P0/pursfAZ1ZigJ –

+0

仍然无法通过azurewebsites访问工作室。不过,根据ayende在RavenDB谷歌集团,这是设计。 –

0

你好,这是回答了RavenDb on Azure Websites - Access Denied 基本上你需要配置在Web.config端口

+0

正如我上面提到的@ SyntaxC4,我尝试了该帖子的解决方案,它不起作用。我拿出指定Port和DataDirectory的配置代码,然后将这些值放入我的Web.config的AppSettings中。仍然有错误。由于该网站在我的本地开发环境中正常工作,因此我目前处于亏损状态。 –

+1

您提到的帖子是正确的,但在我的情况下,它不起作用,因为我还为EmbeddedDocumentStore设置了UseEmbeddedHttpServer = True设置。我相信这可能是RavenDB团队在未来构建中可以解决的问题。 –