RavenDb on Azure Sites - Access Denied

I am playing with the new website feature on Azure and am trying to get an MVC site that works with RavenDB in native mode. Everything works fine locally, but launches a deployed site in azure. I get this error:

System.Net.NetworkInformation.NetworkInformationException: Access Denied

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

Store = EmbeddableDocumentStore { ConnectionStringName = "RavenDb" }; 

My connection string:

 <add name="RavenDb" connectionString="DataDir=~\App_Data\Raven" /> 

Thanks!

+6
source share
1 answer

When the port is not specified for RavenDb, it will exit and try to find its own, it does this by calling IPGlobalProperties.GetActiveTcpListeners ().

RavenDb | PortUtil.cs

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

The call to GetActiveTcpListeners () intern calls the Win32 function GetTcpTable () , which attempts to list the entire possible combination port on the host. For obvious reasons, it would be a good scenario to allow users to scan ports on Windows Azure websites. This means that the GetTcpTable operation fails, and when something fails in the development world, we throw an exception.

In this particular case, the exception is a NetworkInformationException , which raises to security permission, ignoring the GetTcpTable call. This is why this results in an access denied message.

TL; DR

Add the default port to the web.config application settings section:

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

Source: https://habr.com/ru/post/920727/


All Articles