5

I get an Access denied message when I try to deploy my MVC4 site with an Embedded instance of RavenDB to the new Azure Websites preview feature. The site works fine locally.

Here is how I configure 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();

And here is the stack trace when I browse to the site:

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
Chris Swain
  • 5,193
  • 5
  • 21
  • 22
  • Did you notice this thread? http://stackoverflow.com/questions/11529159/ravendb-on-azure-websites-access-denied – cory-fowler Oct 23 '12 at 21:19
  • @MattJohnson - Your comment is referring to Cloud Services while the question is asking about Web Sites. You would be correct if the context was Cloud Services, however, Web Sites allows for a Persistent environment for hosting web applications without the worry of the cache disk clearing upon recycle of the Cloud Service – cory-fowler Oct 23 '12 at 21:22
  • @SyntaxC4 I did notice that thread and tried the solution, but it didn't work for me. – Chris Swain Oct 23 '12 at 22:37

2 Answers2

3

I managed to get it to work, although it is not ideal. You may notice in my original post that I am setting the UseEmbeddedHttpServer = true. This is so that I can browse to http:[MyUrl]:8081 and get the RavendDB Management Studio so that I can browse my data. For some reason, RavenDB wants to do the same kind of port check when this property is set as it does when you set the Port setting to automatic (Port=*).

I believe that RavenDB may need a fix so that it honors the Port setting when UseEmbeddedHttpServer is True and also let you set the Configuration property of the EmbeddedDocumentStore upon creation.

But in the meantime, you can truly get your MVC4 site to work with an EmbeddedDocumentStore on Azure Websites simply by specifying a port. Also, you do indeed have to use the AppSettings configuration rather than setting the Configuration property of the EmbeddedDocumentStore upon creation (like I tried to do above). This post (stackoverflow.com/questions/11529159/) shows how to do it.

Unfortunately, I still haven't found a way to run the EmbeddedHttpServer so I can use the Raven Management Studio. If I figure out how, I will post a solution here.

Community
  • 1
  • 1
Chris Swain
  • 5,193
  • 5
  • 21
  • 22
  • Did you find a sln to this? Or are you still unable to use studio with azurewebsites? – Larsi Nov 23 '12 at 14:05
  • Still unable to use studio with azure websites, but according to ayende in the following thread, this is by design. https://groups.google.com/forum/?fromgroups=#!searchin/ravendb/Azure$20Websites/ravendb/HW463DU27P0/pursfAZ1ZigJ – Chris Swain Nov 23 '12 at 23:20
  • Still unable to access studio via azurewebsites. However, according to ayende over at the RavenDB google group, this is by design. – Chris Swain Nov 23 '12 at 23:23
0

Hi this was answered on RavenDb on Azure Websites - Access Denied Basically you need to configure the port in Web.config

Community
  • 1
  • 1
Nir Mashkowski
  • 265
  • 1
  • 2
  • As I mentioned to @SyntaxC4 above, I tried the solution from that post and it didn't work. I took out the configuration code that specified Port and DataDirectory, and I put those values into the AppSettings of my Web.config. Still got the error. I'm at a loss at this point since the site works fine in my local dev environment. – Chris Swain Oct 24 '12 at 13:24
  • 1
    You are correct that the post you mention will work, but in my case it didn't work because I was also setting the UseEmbeddedHttpServer = True setting for the EmbeddedDocumentStore. I believe this might be an issue that could be fixed by the RavenDB team in a future build. – Chris Swain Oct 24 '12 at 16:19