How to enable CodeLens for viewing Application Insights telemetry directly in Visual Studio for Web API projects

I had been using Application Insights for a while with a Web API project and found it immensely valuable for monitoring how the Web API was performing and discovering any issues in production.

I only recently stumbled across the fact that for ASP.NET projects, the Application Insights telemetry is surfaced and available in your source code within Visual Studio using CodeLens.


I was wondering why I wasn’t seeing this for my project and it seems you only get this magic happening automatically if your project is ASP.NET. My project was a Web API project.

Luckily it didn’t take long to find the answer here:

I followed the steps posted on the comment of this thread. By adding this into an existing Product Group within the project .csproj file.


Note: When substituting values into the above, Resource Group and App Insights are the display name shown in Azure not the ids.

You will need to close and re-open the project in Visual Studio for the changes in the .csproj file to take affect. Once this happens you should be able to right-click on your project in Solution Explorer window and see an Application Insights menu option.

Now you’re all setup, learn more about how to use all this data that is at your fingertips!

Right-click the project and choose Application Insights, Search
Under Request Details, click through to the code

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create a website or blog at

Up ↑

%d bloggers like this: