marc_s
marc_s

Reputation: 755361

Deploy ASP.NET MVC app with SQLite to Azure web site

I have an ASP.NET MVC 5 application including a Web API 2 service, and I published it to my Azure Web Site. The static site works just fine - and the Web API worked, too, while I was serving dummy data.

Since I've added a SQLite database (in a .db3 file inside App_Data), I cannot call my Web API Service anymore - I just get a "An error occurred" message, and I can't seem to find out how to really figure out what's going wrong.

I also installed Elmah.MVC with XML file storage into my application, but when I try to navigate to http://myapp.azurewebsites.net/elmah, I get nothing - as if no errors ever happened...

OK, now I'm stuck - locally on my machine - of course - it all works just fine. But this whole Azure deployment story is a big mystery to me - still.

  1. How do I find any kind of error logs so I could begin to understand what's going on?
  2. Is there any way I can see the files in the file system that make up this app? I'd like to check if all the files I'm expecting to see are really in place

Update: Thanks to David's answer, I was able to get access to "detailed" error pages using FTP (I just somehow remember a demo where log messages were being displayed live, in the portal I believe - seems a bit "clunky" to have to use FTP to get at the logs...)

I get this error (which I totally don't understand and don't know what to do about....)

HTTP Error 500.0 - Internal Server Error

The page cannot be displayed because an internal server error has occurred.

Most likely causes:

IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.
IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.
IIS was not able to process configuration for the Web site or application.
The authenticated user does not have permission to use this DLL.
The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.

Things you can try:

Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.
Check the event logs to see if any additional information was logged.
Verify the permissions for the DLL.
Install the .NET Extensibility feature if the request is mapped to a managed handler.
Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here.

I wish I would have any idea at all how to try any of those "Things you can try" in an Azure Websites setup ...... any takers?

Update #2: with some "arcane" debugging, I was able to figure out that the root error is:

DllNotFoundException: Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

So my question is: what is that SQLite.Interop.dll, and why do I need it?? I just installed the System.Data.SQLite.Core NuGet package (don't need EF6 support etc.) - locally that works just fine, but when deploying to an Azure Web Site, suddenly that extra DLL gets searched and not found.... why is that??

Upvotes: 2

Views: 1643

Answers (2)

Shaun Luttin
Shaun Luttin

Reputation: 141712

The web-based service control manager is your friend. Go to myapp.scm.azurewebsites.net in any browser.

Kudu Service Control Manager

To see the files in the file system, from the service control manager, go to Debug console > PowerShell. This lets you use PowerShell to inspect all the files.

To see log messages being displayed live, from the service control manager, go to Tools > Log stream. This will show you the streaming logs you are wanting.

Upvotes: 4

davidmdem
davidmdem

Reputation: 3823

You can use Diagnostics settings to turn on Web Server Logging and an FTP connection to see the files in the file system.

From either of the Azure portals, open your Web App/Site.

Azure management portal (manage.windowsazure.com):

  1. Turn on Diagnostics. From Configure -> application diagnostics/site diagnostics. Here you can turn on different diagnostic settings. Log files are viewable via FTP.

  2. FTP. From the Dashboard. Listed on the right side of the screen you will find FTP HOST NAME and DEPLOYMENT/FTP USER. The password will be the same as you Deployment Credentials setting.

New Azure portal (portal.azure.com)

  1. Turn on Diagnostics. Settings -> Diagnostic logs. Here you can turn on diagnostics. The FTP host/user settings are here also.

Use Settings -> Deployment credentials to set/reset the FTP password if needed.

Edit:

To view live steams and other performance monitoring, you can use the Tools section in the portal.azure.com manager. It's next to the Settings cog icon and will also give you things like a Console where you can execute limited commands against your host.

Upvotes: 2

Related Questions