Configure Azure Application Insights Automatically in MVC

Kailash Chandra Behera | Tuesday, May 31, 2022


Application Insights helps to monitor and analysing applications which help to increase the performance of application. Here in this blog, we will demonstrate how to Configure Application Insight in MVC.

Getting Started

Before starting the demonstration to configure app insights in MVC applications, let me give you brief details about the application insights.

Application Insights in azure is a feature Azure Monitor that delivers a comprehensive solution for collecting, analysing, and acting on telemetry from your cloud and on-premises environments. This information helps you understand how your applications are performing and proactively identify issues affecting them and the resources they depend on.

There are two ways to configure azure app insights that are manually and automatically. Here we will discuss or demonstrates how to configur automatically. Before continues make sure that you have the following things mentioned below.

  1. Visual Studio 2019 with ASP.NET with web development and Azure development
  2. Azure account
  3. Application insights workspace-based resource.

Create a demo MVC project in Visual Studio 2019 for this demonstration, if you don’t know visit my site Create an MVC Application in Azure to create a demo MVC project.

Add Application Insights automatically

The steps are guided to add azure app insights to MVC application, the blow steps will guide you through automatically adding Application Insights to a template-based ASP.NET web app. From within your ASP.NET web app project in Visual Studio

  1. Select Project > Add Application Insights Telemetry > Application Insights Sdk (local) > Next > Finish > Close.
  2. Open the ApplicationInsights.config file.
  3. Before the closing tag, add a line that contains the connection string for your Application Insights resource. Find your connection string on the overview pane of the newly created Application Insights resource.
  4.  <ConnectionString>Copy connection string from Application Insights Resource Overview</ConnectionString>  
  5. Select Project > Manage NuGet Packages > Updates. Then update each Microsoft.ApplicationInsights NuGet package to the latest stable release.
  6. Run your application by selecting IIS Express. A basic ASP.NET app opens. As you browse through the pages on the site, telemetry will be sent to Application Insights.

You have now successfully configured server-side application monitoring. If you run your web app, you'll see telemetry begin to appear in Application Insights.


Here we demonstrated how to configure app insights in MVC application, I hope you enjoyed it a lot.


No comments: