How to view errors for WebApp in Azure portal and what configuration it is required - azure-web-app-service

I am working on the ASP.Net MVC 4.8 application. It does have Logs file log4net and it was deployed in on-premises. Now it has been migrated to Azure. Now I am trying to find out some errors and other logs information however I am not able to find where to go and look for the logfile. I have two interest, 1 check the error messages and any log information.
If I need to make some changes what would be the easiest and straightforward way to capture logs and view them in Azure portal. As you can see in the picture below unter Monitoring there are many ways are given to see the logs but I am not sure where to go.

The app service will create an application insights of the same name.
This application Insights will contain all the logs regarding the web app along with performance data and other telemetry data too.
You can view logs live under live metrics tab in application insights of the same name as web app .
Here I have deployed a simple mvc app which logs using Ilogger (typical boilerplate app which visual studio provides ) . IT will log once I refresh the page.
Refer these MS DOCS on application insights

Related

Using Application Insights with On-Premise IIS Server

I am trying to debug a dotnet core 5 Blazor Server app which is eating up all the memory of the IIS Server when it is deployed to a local IIS Server.
However, it is not clear what is causing the memory leak.
As far as I have been able to figure out, installing Application Insights should create the logs needed to be able to determine what the issue is.
So I have added App Insights to the Project. When I run the project, I can then see App Insights Events being created in Visual Studio.
However, the issue occurs when the app is published to the Production IIS Server. I don't understand how to view the application insight data from the Prod Server. Are logs being generated?
I have tried to find data on this, but most of what I found is for Azure Application Insights. But the app is not running on Azure.
So how do I view the logs from the Prod Server? Or is there a better way to debug this issue?
So I have added App Insights to the Project. When I run the project, I can then see App Insights Events being created in Visual Studio.
However, the issue occurs when the app is published to the Production IIS Server. I don't understand how to view the application insight data from the Prod Server. Are logs being generated?
Let me get this clear: you have created an Azure Application Insights resource. When your run the project using the debugger you can see telemetry being generated.
Is this correct?
How did you verify telemetry is being generated?
If it works locally it should work when deployed on IIS. Your application will generate telemetry that will be send to the Application Insights resource in de Azure Cloud. It does not matter whether you app is actually hosted on Azure or not in this scenario.
If you are not seeing telemetry make sure the instrumention key is correctly set in the production environment.
There are several ways to explore the telemetry send to Application Insights:
https://learn.microsoft.com/en-us/azure/azure-monitor/app/diagnostic-search
https://learn.microsoft.com/en-us/azure/azure-monitor/app/overview-dashboard
https://learn.microsoft.com/en-us/azure/azure-monitor/logs/queries
After some study, I found the answer to this.
You can use Azure Application Insights to view data collected from an asp.net core app, no matter where the app is actually running. It can be running on-premise, or in the cloud.
The way this works is that in your app, you add a "Connection String" for application insights. The connection string is made available in the Application Insights resource that you create in Azure.
Then you add this connection string to your code in your app. The, when the app runs, whether in Visual Studio, or from a published location, the app send data up to the Azure Resource through an endpoint.
The connection string looks like this:
InstrumentationKey=000000-0000-0000-0000-000000000;IngestionEndpoint=https://eastus2-0.in.applicationinsights.azure.com/
Then you add code such as:
var options = new ApplicationInsightsServiceOptions { ConnectionString = #"InstrumentationKey==000000-0000-0000-0000-000000000;IngestionEndpoint=https://eastus2-0.in.applicationinsights.azure.com/" };
services.AddApplicationInsightsTelemetry(options: options);
There are a number of ways to actually add the connection string. See the docs here
You then log into Azure to view the data collected.

Capture ILogger logs of an asp.net core application on an azure app service

I am working on an asp.net core web application.
This application is hosted on an azure app service.
This application generates log on standard output (dotnet run command). This log comes from ILogger.
How can i see this logs in azure portal ?
Thanks
Check out the following docs
https://learn.microsoft.com/en-us/azure/azure-monitor/app/ilogger
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-5.0
https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-diagnostic-logs
The first doc shows how to use Application Insights for logging. You can capture telemetry such as request duration, dependencies involved in a given request, exceptions, etc.
The second doc shows the various ways to configure ILogger and since ASP.NET Core uses Microsoft.Extensions.Logging.AzureAppService by default, all you have to is enable the logging on the App Serivce, the third doc.

No data for my application insights live metrics with .NET Core 3.1

I'm trying to setup Application Insights on my ASP.NET Core 3.1 web application but without success...
I installed the version 2.16 of "Microsoft.ApplicationInsights.AspNetCore", then add the following line in the startup.cs file:
services.AddApplicationInsightsTelemetry(_configuration);
Moreover, I added the following section in the appSettings:
"ApplicationInsights": {
"InstrumentationKey": "XXX"
}
When I launch this with Visual Studio, I can see data in Live metrics, however, as soon as I deploy this in the production server with IIS, it just display that the application is off. I tried to put the connection string instead, without luck.
I'm suspecting a proxy issue, however, I have no way to be sure of this and it seems unlikely because I'm using the proxy as well on my local machine where it works.
I put the log level of the application on "Information" and I see nothing related to Application Inisights. I even tried to enable the developer mode, it didn't change anything.
The main issue is that I have no error anywhere, so I don't even know what to search :-)
I have encountered the same situation as you, but I'm not sure if we are facing the same error because of no error message.
I have my own ASP.NET Core 3.1 web application and I did the same configuration in my project, and when run it by vs in local environment, azure application insights can show live metrics, when have deployed in azure app service, it shows 'your app is offline'.
In my scenario, it's result from web app instance creation. When I creating an app service, it will create new application insights as default. Like the screenshot below, and of course the new one has different instrumentation key from the key in 'appSetting.json', it caused that when I look into application sights configured in the project, I can't see live metrics but I can see in the application sights that has the same name with app service.
And when creating app service with new application insights, the configuration tab in web app will display some keys like below, and they won't exist if didn't create new insights.
Upon this situation, I tried to modify these two keys with the value of insights that is used in project, and then live metrics worked.
Priority for obtaining the insights configuration may lead to my problem, because there are several ways to set connection.

Application Insights stop working after deployed to Azure

I set up Application Insights on my asp.net core (2.2) app. I can see data in Azure portal when I run my application locally. However, once I deploy it to App Service in Azure, Application Insights stop working - there is no data flow at all. Are there any additional steps I am missing?
Adding to Stuart's comments- > If you edited ApplicationInsights.config, kindly check the configuration of TelemetryInitializers and TelemetryProcessors. An incorrectly-named type or parameter can cause the SDK to send no data.
Also, in the Application Insights portal, open Diagnostic Search. Data usually appears here first. Refresh to see if it helps.
If feasible, you may restart the app and check to see if that helps.

how to diagnose azure problems

I've recently starting experimenting with azure cloud hosting and my web app had about 10 minutes down time today.
I'm not sure why and I was wondering what tools I have available for determining the cause of the downtime.
You have application logs and site logs. Basically application logs are information produced by your web app code. You can use instrumentation to trace call and exceptions in your appliction. Site logs are information produced by the web server and you can see error messages and failed request tracing without instrumenting your code. You won't have relevant information now since by default all diagnostics are turned off but if it happens again you know where to look for.
Here's how to enable and visualize this information.
Enable diagnostics logging for web apps in Azure App Service
https://azure.microsoft.com/en-us/documentation/articles/web-sites-enable-diagnostic-log/

Resources