I have an ASP.Net Web API 2 project. In the controller in a static constructor an Infer.Net model gets initialised. When I run the project locally, either by choosing the web application as the start-up project in Visual Studio 2013 or by choosing the Azure Cloud Service project as the start-up project it works fine, the static constructor runs and the web API calls return the expected values.
However when I deploy the site to Azure and try to call any of the web API controller's methods they fail and I get the exception System.InvalidOperationException
with the explanation
An error occurred when trying to create a controller of type 'TwentyQuestionsController'.
Make sure that the controller has a parameterless public constructor.
(It does.)
Looking into the detail of the inner exception the next exception is a System.TypeInitializationException
The type initializer for 'GuessingGamesWebApplication.Controllers.TwentyQuestionsController'
threw an exception
and further down the stack trace I see a System.UnauthorizedAccessException
Access to the path d:\windows\system32\inetsrv\GeneratedSource' is denied
It looks like when I run the project locally the web role process has sufficient privileges for Infer.Net to build and compile the local files that form the model but in Azure the web role process lacks those privileges.
How do I deploy an ASP.Net Web API 2 web role to Azure with sufficient privileges for Infer.Net to build and compile the local files that form the model?
(N.B. I'm using Infer.Net 2.6.41114.1 via NuGet.)
========== EDIT ===========
Looking at this answer to the question Can I write to file system on azure web site? the web role write permissions are limited to the root folder of my app. So an alternative solution would be to configure Infer.Net to write there instead of in d:\windows\system32\inetsrv\
. How do I configure Infer.Net to do that?