Azure 网站上的 RavenDb - 拒绝访问 [英] RavenDb on Azure Websites - Access Denied

查看:35
本文介绍了Azure 网站上的 RavenDb - 拒绝访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Azure 上的新网站功能,并尝试让 MVC 站点在嵌入式模式下使用 RavenDB 运行.在本地一切正常,但在 azure 中运行部署的站点时出现此错误:

I'm playing around with the new Websites feature on Azure and trying to get an MVC site running with RavenDB in embedded mode. Everything works fine locally but running the deployed site in azure I get this error:

System.Net.NetworkInformation.NetworkInformationException:访问被拒绝

System.Net.NetworkInformation.NetworkInformationException: Access is denied

当我在 global.asax 中创建数据库实例时会发生这种情况:

This happens when I create the db instance in global.asax:

Store = EmbeddableDocumentStore { ConnectionStringName = "RavenDb" };

我的连接字符串是:

<add name="RavenDb" connectionString="DataDir=~App_DataRaven" />

谢谢!

推荐答案

当没有为 RavenDb 指定端口时,它会出去并尝试找到它自己的,它通过调用 IPGlobalProperties.GetActiveTcpListeners().

When a port is not specified for RavenDb it will go out and attempt to find it's own, it does this by calling IPGlobalProperties.GetActiveTcpListeners().

RavenDb |PortUtil.cs

var activeTcpListeners = IPGlobalProperties
                         .GetIPGlobalProperties()
                         .GetActiveTcpListeners();

调用 GetActiveTcpListeners()intern 调用 Win32 函数 GetTcpTable() 尝试枚举主机上所有可能的端口组合.出于显而易见的原因,允许人们在 Windows Azure 网站中进行端口扫描并不是一个好的方案.这意味着 GetTcpTable 操作失败,并且当开发世界中出现问题时,我们会抛出异常.

Calling GetActiveTcpListeners() intern calls the Win32 function GetTcpTable() which attempts to enumerate all of the possible port combinations on the host. For obvious reasons, it would not be a good scenario to allow folks to do port scanning within Windows Azure Web Sites. Which means the GetTcpTable operation fails and when something fails in the world of development we throw an exception.

在这种特殊情况下,异常是 NetworkInformationException 引发的安全权限忽略了对 GetTcpTable 的调用.这就是导致访问被拒绝消息的原因.

In this particular case the exception is a NetworkInformationException which is raised do to the security permissions neglecting the call to GetTcpTable. This is why it results in an Access Denied message.

tl;dr

将默认端口添加到您的 web.config appsettings 部分:

Add a default port to your web.config appsettings section:

 <appSettings> 
    <add key="Raven/Port" value="*"/> <!-- Add real tcp port # -->
    <add key="Raven/DataDir" value="~Data"/> 
    <add key="Raven/AnonymousAccess" value="Get" /> 
 </appSettings> 

这篇关于Azure 网站上的 RavenDb - 拒绝访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆