Hi all;
Sorry - this is a long one. (But hopefully not that complex.)
I have a Blazor Interactive Server app using ASP.NET version 8. And using Entity Frameworks for accessing the DB and the ASP.NET Identity Library for users & claims.
I initially had Application Insights incorporated in my app using the SDK, adding the code by hand, and turning it on in the Azure App Services blade. When I learned this was duplicative, I then turned it off in the Azure App Services and commented the code out.
I did keep the library Microsoft.ApplicationInsights.AspNetCore added via NuGet. And I kept the Application Insights service I had created in Azure. My Azure App Service has a production slot with 2 instances and the dev slot with 1 instance.
I then ran the Visual Studio: Configure Application Insights… | Azure Application Insights. I then selected my Subscription name and Application Insights instance.
This works! Application Insights is now showing data from my App Service. This question is to make sure it is all configured correctly. And to ask a couple of follow-up questions.
Note I changed any guid to GUID in case any are credentials.
BTW - I read a lot of web pages including this one and watched all 3 Pluralsight classes on Monitoring & Application Insights. The below questions are issues that were either not covered, said something different from what happened, or had conflicting advice.
- It added to my app.web.csproj the following. What is this:
<ApplicationInsightsResourceId>/subscriptions/GUID/resourceGroups/Louis_Howe/providers/microsoft.insights/components/LouisHowe</ApplicationInsightsResourceId>
- It added the following to my secrets.json. What is all of this?
"APPLICATIONINSIGHTS_CONNECTION_STRING": "InstrumentationKey=GUID;IngestionEndpoint=https://eastus-8.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/;ApplicationId=GUID"
- I have left over in secrets.json the following. Do I delete this now as it was from my previous effort to add AI?
"ApplicationInsights:ConnectionString": "InstrumentationKey=GUID;IngestionEndpoint=https://eastus-8.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/"
- It added the file Properties/ServiceDependencies/local/appInsights1.arm.json – what is this for?
- It added an appInsights1 section to the files Properties/serviceDependencies.json and Properties/serviceDependencies.local.json – what are these for?
- It also put the AI connection string in appSettings.json under ApplicationInsights:ConnectionString. I should delete this, keep it in secrets.json, and put this in my KeyVault – correct?
- Visual Studio added no code to Program.cs (the documentation said it would). So I added the following. Is this correct? And is the EnableSql needed to get the queries in AI? I expect something so fundamental would be enabled by default.
builder.Logging.AddApplicationInsights();
builder.Services.AddApplicationInsightsTelemetry();
builder.Services.ConfigureTelemetryModule<DependencyTrackingTelemetryModule>((module, o) => { module.EnableSqlCommandTextInstrumentation = true; });
thanks - dave