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

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.

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.

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.

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

services.AddApplicationInsightsTelemetry();

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

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

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

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.

For more details, check out the Microsoft official documentation.

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

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store