Introduction
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.
- Visual Studio 2019 with ASP.NET with web development and Azure development
- Azure account
- 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 automaticallyThe 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
- Select Project > Add Application Insights Telemetry > Application Insights Sdk (local) > Next > Finish > Close.
- Open the ApplicationInsights.config file.
- 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.
- Select Project > Manage NuGet Packages > Updates. Then update each Microsoft.ApplicationInsights NuGet package to the latest stable release.
- 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.
<ConnectionString>Copy connection string from Application Insights Resource Overview</ConnectionString>
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.
Summary
Here we demonstrated how to configure app insights in MVC application, I hope you enjoyed it a lot.
Thanks