Azure网站上的RavenDB嵌入式 - 访问被拒绝

时间:2012-10-23 14:55:37

标签: ravendb azure-web-sites

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

以下是我配置Raven的方法:

//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

2 个答案:

答案 0 :(得分:3)

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

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

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

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

答案 1 :(得分:0)

您好RavenDb on Azure Websites - Access Denied 基本上你需要在Web.config中配置端口

相关问题