Master ASP.NET Core Performance Monitoring: 5 Steps to Integrate Azure Application Insights
Hey there, my tech-savvy pals! Get ready to supercharge your ASP.NET Core app with some hilarious help from Azure Application Insights! đ
- azure
- observability
Hey there, my tech-savvy pals! Get ready to supercharge your ASP.NET Core app with some hilarious help from Azure Application Insights! đ
Overview
Picture this: your appâs performance is like a rollercoaster ride, and you desperately need to keep tabs on it. Thatâs where the mighty Application Insights swoops in to save the day!

Getting Started
To get started with integrating Azure Application Insights into your ASP.NET Core application, follow these 5 simple steps:
Step 1: Time to Create Some Azure Magic! đŠ
Head over to the Azure Portal and type in âApplication Insightsâ like youâre casting a spell. Click on âCreate,â fill in the wizardry details, and tap âReview + Create.â Voila! Your very own Application Insights instance will appear like magic beans!
Donât worry about distance; just pick the region closest to your appâs hideout. And if you need a new group to join the adventure, you can create one there too!

Step 2: Prepare Your ASP.NET Core Superhero Team! đڏââď¸
Open your ASP.NET Core project in Visual Studio, and itâs time to summon the âMicrosoft.ApplicationInsights.AspNetCoreâ Nugget Package! Abracadabra! đŞ

Now, before we dive into the magic, you need some essentials:
- A kickass ASP.NET Core application (if you donât have one, you can cook up one like the following images or you can follow ASP.NET Core tutorial).
Note: As Iâm a Macie , this is for Mac. If you are using Windows please consider the link for it.


- The Application Insights NuGet packageâââa friend you can trust!
- A secret Application Insights connection string to send all the juicy info.

Step 3: Enable Application Insights Server-Side Telemetry
Using Visual Studio:
- Open your project in Visual Studio.
- Go to âProjectâ > âAdd Application Insights Telemetry.â
- Select âAzure Application Insightsâ > âNext.â
- Choose your subscription and existing Application Insights instance or create a new one using âCreate new.â
- Add or confirm your Application Insights connection string and select âFinish.â
- After adding Application Insights to your project, ensure you are using the latest stable release of the SDK by going to âProjectâ > âManage NuGet Packagesâ > âMicrosoft.ApplicationInsights.AspNetCore.â Update it if needed.
Without Visual Studio:
- Install the Application Insights SDK NuGet package for ASP.NET Core. Use the latest stable version for optimal performance.
- In your projectâs .csproj file, add the following code under
<ItemGroup>:
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
- Prepare for the grand finale! Add this epic line to your startup.cs or program.cs class (you decide, magician!): For ASP.NET Core 6 and later:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddApplicationInsightsTelemetry();
builder.Services.AddMvc();
var app = builder.Build();

Step 4: Time to Get Charmed with the Connection String! đŽ
Unlock the secret door by adding the connection string. You have two choices, just like choosing between two different spellbooks:
Option 1: Specify the connection string in the âappsettings.jsonâ configuration file:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ApplicationInsights": {
"ConnectionString": "Copy connection string from Application Insights Resource Overview"
}
}

Option 2: The Environment Variable Spellbook (For Advanced Wizards!):
You got the knack! Just set the âAPPLICATIONINSIGHTS_CONNECTION_STRINGâ environment variable or âApplicationInsights:ConnectionStringâ in the JSON configuration file.
Step 5: The Grand Finale! đ
With the connection string in place, your setup is complete! Now you can run your application and explore logs and live metrics in the Azure Portal.

Monitoring Your Application
Zoom in on the live tracking and performance monitoring featuresâââwatch your app dance like nobodyâs watching!
Live Metrics

Performance

Enjoy the journey of monitoring and optimizing your ASP.NET Core application with Azure Application Insights! If you encounter any issues or have questions, feel free to make a comment!
For more mischief and witty wizardry, hop over to the official Microsoft documentation! Embrace the fun, and happy monitoring! đ§ââď¸đ¤Š
