I have an ASP.NET Core application running as Azure App Service. Azure Application Insights is enabled (I followed these instructions). The problem is my instance of Azure Insights on Azure Portal isn’t showing any useful data except for Live Metrics (see the screenshot). As you can see there are multiple requests and custom events on the screenshot.
However, when I open Transaction search it shows nothing (see the screenshot).
Events page is empty as well (see the screenshot).
So far I double-checked an InstrumentKey. Also I tried to use ConnectionString instead of InstrumentKey, but it didn’t help.
My app is running on .NET Core 3.1. I installed the latest version of Microsoft.ApplicationInsights.AspNetCore package which is 2.19.0.
Here is how logging is configured in Program.cs:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureLogging(builder =>
{
builder.AddFilter<ApplicationInsightsLoggerProvider>("", LogLevel.Information);
});
And below is code from Startup.cs:
services.AddApplicationInsightsTelemetry(new ApplicationInsightsServiceOptions
{
ConnectionString = Environment.GetEnvironmentVariable("APPLICATIONINSIGHTS_CONNECTION_STRING")
});
LogLevel is also configured in appsettings.json:
"Logging": {
"LogLevel": {
"Default": "Warning"
},
"ApplicationInsights": {
"LogLevel": {
"Default": "Information"
}
}
Update:
My Admin who has more permissions can see all data, including events, performance operations etc. So I suppose there’s something to do with permissions. Though it’s strange that I’m not seeing any warning messages. The Admin assigned me more roles (see the screenshot), but it didn’t make any difference.
I would appreciate any help on this issue!
2
Answers
After tearing almost all hair off my head I finally solved the issue! Turned out the instance of Azure Application Insights was linked to a Log Analytic Workspace that belonged to a Resource Group to which I didn't have access. So logs were stored properly, but I didn't have permission to read them. My admin solved the issue by creating a new instance of Azure Application Insights which was linked to a Log Analytic Workspace within my Resource Group. To anyone who isn't familiar with Log Analytic Workspace - it can be specified when you create a new instance of Azure Application Insights (see the screen).
Thanks everyone for trying to help me!
UPDATE: As Jonathan L. mentioned in the comments, instead of creating a new Application Insights instance, one can just change Workspace in Properties.
I have tried the same and can able to see the logs inside portal .
As Peter Bons suggested make sure that you are using
ILogger
in your controller .Here are the steps i have followed .
GitHub
and after extract open project in Visual studio and configure with Application insight telemetry . Updated latestMicrosoft.ApplicationInsights.AspNetCore
to 2.19.0And added instrumentation key in my
appsettings.json
which copied from Azure portal>Application insight(my applnsight)>overview.Ilogger
configuration in mycontroller.cs
In
startup.cs
addedAfter all that above configuration run the application and navigate to Azure portal to check the logs .
Make sure that you have provided the log information which you want to check as example in my
controller.cs
.from the logs we can see the exceptions/errors with line of code as well .
Here are some screenshot for reference:
For more information please refer this SO Thread .