Using Application Insights right from the Visual Studio 2015

Using Application Insights right from the Visual Studio 2015

Visual Studio 2015 offers a set of tooling capabilities for Application Insights to enhance the developer experience and productivity. That supports create, configure and manage Application Insights for your application right from Visual Studio and without even opening the Azure Portal.  In one of my previous post – Adding Application Insights to a Windows 10 Universal App, you have seen how to create an Application Insights from Azure Portal, and later on using it for a Windows Universal App.  This post will give you an quick overview of different tooling support of Visual Studio 2015 that may help you to expedite your process of using Application Insights.

So, let’s start exploring..

1. Adding Application Insights from New Project Window Dialog Window

To create and add an Application Insights you really don’t need to start with the Azure Portal. When you’re creating a new Visual Studio 2015 project  select the checkbox “Show telemetry in the Windows Dev Center” and “Enable richer analytics with Application Insights”. as seen in this screenshot.

P.S : You will find these option only for the project types which are support by Application Insights

Then Select your Azure subscription account, and select “New Application Insights Resource” – (Project Name) .. from send your Telemetry dropdown.

Create and add a new Application Insights from New Project Window Dialog

Here you may select any existing Application Insights as well , but let’s leave that for now, as we have already seen this in previous post.

Click on OK. That’s it.

Visual Studio will start creating a new solution for you, along with all required components to start using Application Insights.

Create and add a new Application Insights from New Project Window Dialog

Here is the initial solution structure with all components. with this process, the name of application insights will be remain same with the name created project.

Create and add a new Application Insights from New Project Window Dialog

In the backend, Visual Studio also create the Developer Services for your Application insights on the selected Azure Account.

Open the Azure Portal and search for all resources, you should be able to see your newly created application insight.

Create and add a new Application Insights from New Project Window Dialog

P.S :  At this point of time You won’t be able to see the application insight on  the portal dashboard . You need to manually pin it to dashboard for quick access.

2. Configure  New Application Insights During Creation

In the first example, you have seen the application insight was getting created with project name and with some default resource and location selected.

Incase if you want to provide a new name, and want to change the resource as well as location, you can select the “Configuration Settings..” options.  A new “Configuration Settings for Application Insights” dialog window will appear where you can provide required information .

image

3. Adding or Configuring Application Insight from Solution Explorer

If you missed to add the application insight during the project creation, no need to worry ! There are several ways of doing that.  You can Add or configure Application Insights from Project Solution Explorer

Right Click on Project –> Select “Add Application Insights Telemetry” from the context menu.

Adding or Configuring Application Insight from Solution Explorer

A new “Application Insights” window will appear, where you can select your Microsoft Account and corresponding Azure subscription to start creating a New  Application Insights.

Adding or Configuring Application Insight from Solution Explorer

Similarly, when you have Application Insights is already added, you can select any of the following options.

  • Open Application Insights
  • Configure Application Insights

image

While Open Application Insights will take you to Azure Portal, Configuration option will open option like below ( Similar to Add) where you can configure your existing information’s.

Adding or Configuring Application Insight from Solution Explorer

4. Configuring Application Insight from Solution Explorer – Application Insight Config Files

In the solution Explorer, you can select the “ApplicationInsights.config” file to open the portal and view the telemetry data or even configure / change / update your existing Application insights.

Configuring Application Insight from Solution Explorer – Application Insight Config Files

On the other hand, when application insights is added, you can select the Overview components to open the portal

 5. Use Add Connected Service To Add Application Insight

You can add an Application Insights using “Adding Connected Services” features. Visual Studio 2015 helps us quickly build connected cloud application using “Add Connected Services” feature. “Adding Application Insights” is one of them.

Right click on “References” and select “Add Connected Service” from context menu.

 

Related Post : Connecting Azure Storage Using Add Connected Services

 

Use Add Connected Service To Add Application Insight

Add Connected Service dialog window will appear. Select “Application Insights” and then click on “Configure” .

Use Add Connected Service To Add Application Insight

A configuration window similar to what we have seen previously will appear to add / configure the Application Insights.

That’s all. Hope this will give you very good start of using Application Insights from Visual Studio Itself.

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.