Search code examples
azureasp.net-core-mvc.net-6.0azure-application-insights

Configure App Insights for .net 6 web application


I have a .net 6 web app and is deployed to an azure app service. I wanted to configure app insights for it. The app insight is deployed and is enabled when you check the Application Insights menu under Settings of app service.

I am following the below link

Application Insights for ASP.NET Core applications

The instruction I am stuck at it Go to Project > Add Application Insights Telemetry.

I use my Visual studio with my organization id and the deployment is happening to client tenant. The id is only used for accessing client azure portal subscription and nothing else. When I go to the suggested menu option (as above) I get a pop up which has my org id and the subscription and resources under it. How do I perform this step without adding the account I use to access client azure portal?


Solution

  • How do I perform this step without adding the account I use to access client azure portal?

    To configure Application Insights without providing the Azure account, you need to select the Application Insights Sdk (Local).

    enter image description here

    It clearly says that this dependency is used to track and monitor the Performance of the WebApp without connecting to an instance in Azure.

    enter image description here

    I see service dependencies json file along with local version created in my web app project

    Yes, serviceDependencies.json, gets added when we add the Local SDK.we do not configure anything in the created file.

    enter image description here

    If you are using the latest .NET Core 6 or later version, the below line of code gets added in the Program.cs file.

    builder.Services.AddApplicationInsightsTelemetry();
    
    • As you are using .NET 5, I don`t see any code added.

    • In Startup.cs file, Add the below line under ConfigureServices.

    services.AddApplicationInsightsTelemetry();
    
    • In appsettings.json file add the configuration same as mentioned in this Link.

    Output:

    enter image description here