0
votes

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 :-)

1
One option is to run Fiddler and see what's going on on the wire.ZakiMa

1 Answers

1
votes

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.

enter image description here enter image description here

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.

enter image description here

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.

enter image description here

Priority for obtaining the insights configuration may lead to my problem, because there are several ways to set connection.

enter image description here