5 Easy Steps to Integrate Azure Application Insights into Your ASP.NET Core Application for Performance Monitoring

Bharat Dwarkani
3 min readApr 17, 2021

--

This article will guide you on how to add Azure Application Insights in your ASP.NET Core application for tracking application performance.

Application Insights, a feature of Azure Monitor, is an extensible Application Performance Management (APM) service for developers and DevOps professionals provided by Microsoft Azure. Use it to monitor your live application performances.

Creating Application Insights new instance in Azure Portal

Step 1: Go to Azure Portal and search for Application Insights.

Application Insight in Azure Portal

After opening, the Application Insights page, click create and fill details in the form, and click on Review + Create. In few minutes, your instance will be created.

You can select the region nearest to your web app-hosted location. If you don’t have a resource group you can create a new one.

Create Application Insight

Setting up your ASP.NET Core MVC application for monitoring

Step 2:
Open your ASP.NET Core project in Visual Studio. Search and install Microsoft.ApplicationInsights.AspNetCore Nugget Package.

Microsoft.ApplicationInsights.AspNetCore

Step 3: Configure Application Insight service in Startup.cs file ConfigureServices method by adding this line

services.AddApplicationInsightsTelemetry();

Register App insights in startup

Tip: After testing with the above code, you can add below code to restrict logging metrics in a development environment

Adding application insights in production environment

Step 4: Get the Application Insights Instrumentation key from Azure Portal

Get Instrumentation Key from Azure Portal

Step 5: Include the Application Insights instrumentation key in your project appsettings.json file.

Adding application insight key

Tip: Instrumentation Key can also be injected via environment variables.

ApplicationInsights__InstrumentationKey: "your-key"

That’s it !!! Setup is complete

Now you can run applications and explore logs and track live metrics in Azure Portal.

Live Tracking
Performance Monitoring

For more details, check out the Microsoft official documentation.

Originally published at https://blog.sharetechlinks.com on April 17, 2021.

--

--

Bharat Dwarkani

Tech Enthusiast, Full Stack Software Engineer, Product Manager, Engineering Enterprise SaaS product