View Azure cloud service IIS logs - asp.net-mvc-3

I have created a simple MVC3 site that displays data from a table in an Azure database. I have created a cloud service to run the site in and can publish it successfully. I have also run the site successfully in the Azure emulator.
My problem is that when I select the page that displays the data there is an error as I get the default error page. I think I have the db connections set correctly but I cannot see any logs. So my questions are:
Where are the IIS logs? I would like to see what the error is.
Are there any other logs/diagnostics that I can use to see what the problem is?
Thanks.

By default the only place where something might be logged is in the Windows Application Event Log. You'll need to Remote Desktop to the cloud service instance (Connect from the Instances page in the Azure Management Portal) and then open Event Viewer.
The IIS logs themselves should be available too although as per normal IIS logs these won't contain exception details. Use IIS Manager > Application > Logging when logged on to the instance to find the location.
As suggested by Magnus, you should use something like Windows Azure Diagnostics and/or ELMAH and/or log4net to log exception and diagnostic information to somewhere accessible for troubleshooting.

I suggest you use Windows Azure Diagnostics to collect your logs.
You can read all(setup and usage) about it here:
http://msdn.microsoft.com/en-us/library/windowsazure/gg433048.aspx

Related

.NET 6 webapp returns 503 error on random intervals

I published a simple .NET 6.0 web app with user authentication on my IIS 10.0 web server hosted on Azure.
The application read and write data from a SQL Server 2017 database hosted on another machine on the same virtual network of the web server.
Everything works fine but after a while, even though nobody is using the app, it stop working and send Http Error 503 Service Unavailable and I have to restart it every time from the application pool.
I enabled tracing on the event log, but I don't receive any message explaining this.
These are the application settings:
IIS application settings
I tried to follow these advices but none of them worked:
IIS HTTP Error 503. The service is unavailable
503 “Service Unavailable” error for all apps after installing .NET Core 2.2 Runtime & Hosting Bundle for Windows
.Net core Service Unavailable after Publish to IIS
On the same web server I have other applications but this problem appears only on this one. None of the other apps is using .NET 6, most use .NET Framework 4.7/4.8 and another couple .NET Core 3.1.
I also tried to publish the application on Azure WebApp service and it has the same problem.
1. If you're deploying on IIS, we can install DebugDiag Tools and then use the DebugDiag collection to crawl the dump logs.
2. If you are using the azure app service, it is recommended to get dump in the azure portal.
My Suggestion
Enable Failed Request Tracing, and find which request will cause the Http 503.
Maybe this 503 is not a problem with the code, and it is possible to find some useful information in the log.
Check the EventViewer, try to find the useful info about the application.
Download the DebugDiag Tools, use debugdiag collection to collect the dump file when the issue occured, and use the debugdiag analysis to analyze the dump file and check the stacktrace.
My suggestion can't tell you the root cause directly, but it will help you to find it. You are also welcome to update the useful stacktrace information in the future, and there will be more people to help you.
I'm currently having the issue but using MySQL on a remote server.
Azure WebApp, Azure VM (IIS 10) and AWS EC2.
Http Error 503 Service Unavailable when the database connection timesout or fails to connect and the AppPool failed to restart.
No crashes when debugging in VS via console app.
I changed the hosting model to out-of-process and this solved the issue.
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="outofprocess">

Get remote errors in Service Fabric using Web Api

Web API has GlobalConfiguration.Configuration.IncludeErrorDetailPolicy
= IncludeErrorDetailPolicy.Always; to turn on remote errors. (Allowing them to see them in a browser even if you are not browsing on the local machine.
But, near as I can tell, Service Fabric, running Web Api, does not support GlobalConfiguration.
Is there a way to configure things so I don't have to log into one of my Service Fabric server machines each time I want to see what a services error message is?
I recommend you don't show error details to everyone.
It's a security risk.
Consider moving your error logs out of your cluster. For instance, by using OMS, ELK or Application Insights.

AppHarbor's IIS logs

Is there a way to get the IIS logs for a website hosted on AppHarbor? I have one site hosted on it and I am getting run time exception. Currently I get a suggestion that I should enable custom errors to view the exception. I don't want to do this since it is a deployed instance which is being used by users.
The IIS logs are not currently available but you can access unhandled exceptions in the error interface on AppHarbor.
You can also use something like Elmah (appropriately locked down) to record and inspect errors.
We're working on making HTTP access logs available too.

azure web application not working from azure--no errors

I created a webapplication using Visual Studio2010 MVC3 .I am able to run this application successfully on my computer emulator.Then I deployed this to azure and is not working.I cant see any errors .The only message I can see on screen is "Internet Explorer cannot display the webpage " .Any suggestions?
By default, the MVC3 template sets up session state management via SQL Express (you can verify this by looking at web.config). This works great locally but not in Windows Azure, since SQL Express won't be running there. Just change your database connection to point to SQL Azure (or disable session state) and hopefully you'll be back up and running again.
Nate Totten wrote a bit more on this topic, here.
I think it's some connection problem, not your code problem since you got the "internet explorer cannot display the website".
I would suggest you RDC to your VM and open the IIS and browse your website, to check if the deployment is correct. And then you can try to go to your website from you machine by the VIP instead of its domain name. For example http://XXX.XXX.XXX.XXX/ instead of http://yourwebsite.cloudapp.net/. If it works then I think you'd better recreate the hosted service and have another try.
HTH

Debugging Topshelf service that won't run under restrictive account

I have a Windows service written using Topshelf. I'm trying to configure it to run using a Windows account with restricted privileges rather than using LocalSystem. That's also necessary as I'd like to connect to a database using integrated authentication.
The service works when run as LocalSystem (albeit with a database connection string containing credentials) and running the console application as my limited account (using runas) also works.
However, when I try to start the service the service control manager times out waiting for a response:
The service did not respond to the start or control request in a timely fashion.
I also get the following in the Application Popup event log:
Application Error : The exception unknown software exception (0xc06d007e) occurred in the application at location 0x77e4bef7.
The first thing that the application does is writes to a log file but it doesn't reach that when I start the service. The logging works if I run via the console.
Any suggestions what I might be missing or what I might try next?
This problem seems to be related to the server (a domain controller) rather than TopShelf. A service built with the .NET service component also exhibits the same behaviour.
The service runs successfully on a different machine (in the same domain).
Unfortunately this doesn't help diagnose the problem but gives me an acceptable workaround.
Check the MSDN article Debugging windows services which describes how you debug windows services.
I've just started seeing this on a few of my services written in .net 2.0. They'll start fine when the server boots, but if I were to restart them throughout the day, they would not start, and give this error message.
They currently ran under a domain account which has admin rights on the box, but for kicks, I switched it to Local System, and the service started normally. I stopped it, changed it back to the domain account (reentering the password), and it started normally again as expected.
Don't know if this counts as a 'fix' so much, but that's what worked for me.

Resources