Using Application Insights with On-Premise IIS Server - azure

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.

Related

How to view errors for WebApp in Azure portal and what configuration it is required

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

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.

How does adding the Microsoft.ApplicationInsights NuGet for a .Net WebAPI project interfere with activating AI via the Azure Portal?

BASIC DESCRIPTION/CONFIGURATION:
We have a .Net Framework 4.6.1 (based upon ServiceStack) WebAPI hosted as Azure WebApp in the Cloud.
Each release-version of our API gets its own Application Insights telemetry endpoint, but we never activate Application Insights for our project in Visual Studio. Instead, after swapping a new releasable version from the staging to the production slot, we activate Application Insights via the Azure Portal, and by that we automatically receive all the request-telemetry that we need out of the box. In the configuration section of our WebApp I can see that some AI-specific Keys were added, most importantly the “APPINSIGHTS_INSTRUMENTATIONKEY”.
This used to work fine. Now I had to implement a feature to be able to send some custom information from our code to application insights.
Herefor I added the Microsoft.ApplicationInsights NuGet package (2.13.1) to our project. In our first scenario I send a custom exception via:
_telemetryClient.TrackException(…)
To test the new feature I created a Development Application Insights resource in the cloud and added the corresponding instrumentation key to our app.config. This works as expected and I can see the exception which I send here in the AI-Instance in the cloud.
NOW THE PROBLEM:
When I publish the app with the new feature to the staging slot in the cloud an then activate application insights via the portal, then I do not receive any standard request-telemetry data any more, only my custom exceptions.
1.) How is request data collected anyway when activating AI via the portal? I cannot find any dlls which would be added to our app hereby, so I suppose that the IIS-Server which hosts our web app collects and transmits the data?
2.) Does the server detect that there is a Microsoft.ApplicationInsights.dll in our code and by that stop collecting the request data because it expects that we handle this in our code ourselves?
The main reason why I do not want to simply activate the full-stack Application Insights feature for our project in Visual Studio is, that it installs a lot of dependencies which trigger DLL-Hell because we need some older versions for these dlls for other dependcies in our app (System.Net.Http for example)

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 get the Dependency calls in Application Insights using NodeJS Web application

I have developed a NodeJS web application, which I published it into azure web app and configured the application insights for that. Up to now every thing was working properly, one thing is when I go to application insights I am able to see only requests, events and exceptions but I am not getting any SQL dependency calls in AI, even though I am getting the data from Azure SQL Database.
I just followed the below link to configure the application insights for my NodeJS web application.
https://learn.microsoft.com/en-us/azure/application-insights/app-insights-nodejs
Can you please tell me how to resolve the above issue as soon as possible?

Resources