May 2014

Volume 29 Number 5

Visual Studio 2013 : Next-Generation Development with Application Insights

Charles Sterling | May 2014

The pace of software delivery has increased dramatically over the past few years. Developers have evolved from waterfall to agile to today’s continuous release cadence. In doing so, the need has intensified for better, faster and more direct feedback. Responsiveness is the name of the game. Decision makers need tools that provide integrated analytics, and make timely data instantly available to the entire team.

The new Microsoft Application Insights, announced at the Visual Studio 2013 launch, is a suite of services designed around the key questions high-performance delivery teams need answered: Is our application available? Is it performing? Are we delivering the features our users want?

Application Insights isn’t limited to operations. To eliminate handoffs and speed up the flow of information throughout the team, it integrates with tools developers and operations already use—Visual Studio and Visual Studio Online. This makes it easy for all team members to get the information they need.

Application Insights is designed to work with services built into the Microsoft .NET Framework, Java, Microsoft Azure services, Web sites, Windows Store applications and Windows Phone 8 applications. With complete end-to-end monitoring, you get a true 360-degree picture of your application, not just small pieces of isolated data.

Getting Started with Application Insights

Getting started with Application Insights is simple. To add the Application Insights telemetry to Web, Windows Phone or Windows Store applications, download the Application Insights Tools for Visual Studio extension, which you’ll find in the Visual Studio Gallery ( Future versions of Visual Studio won’t require this extra step.

For new Projects in Visual Studio 2013, select Add Application Insights to Project when you create a new Project (see Figure 1).

Add Application Insights to New Visual Studio 2013 Projects
Figure 1 Add Application Insights to New Visual Studio 2013 Projects

To use Application Insights with existing applications, right-click on the project and choose Add Applications Insights Telemetry to Project (see Figure 2).

Right-Click to Add Application Insights to an Existing Project
Figure 2 Right-Click to Add Application Insights to an Existing Project

After adding Application Insights, your project will have three new nodes with shortcuts to Availability Monitoring, Performance Monitoring and Usage Analytics data in Visual Studio Online (see Figure 3).

New Nodes Appear in the Enabled Project
Figure 3 New Nodes Appear in the Enabled Project

Implement Usage Monitoring

Once you’ve added Application Insights to a new or existing project, usage monitoring on your Web, Windows Store, and Windows Phone applications is automatically enabled. For older and non-­Visual Studio Web applications, you can add this same functionality by inserting a block of JavaScript into your application. You can get to this JavaScript block by clicking Add Application (see Figure 4) or by going to the Control Panel and selecting Get configuration keys and downloads.

Select Add Application to Add JavaScript Block to Older Apps
Figure 4 Select Add Application to Add JavaScript Block to Older Apps

Implement Performance Monitoring

Despite the name, Performance Monitoring gives you a ton of information beyond just performance data. It will notify you of exceptions, call stack information, dependency information, object allocation and even information about the under­lying infrastructure. Microsoft Monitoring Agent (MMA) also automatically collects the IntelliTrace logs for exceptions and slow calls in your code. In most cases, you can activate performance monitoring by simply installing MMA, which you’ll find at

When you install MMA, it will default to monitoring all Web applications on your machine. This is probably fine for a development box, but might not be ideal for production servers with many Web applications. MMA shouldn’t cause any more than a 5 percent performance degradation while monitoring your application.

To enable MMA on applications you add later, you can easily manually activate monitoring via a Windows PowerShell command:

Start-WebApplicationMonitoring -name "" -mode Monitor -outputchannel cloud

In future releases of MMA and Visual Studio, you won’t need to take this step.

You can also activate performance monitoring on Java and Microsoft Azure applications. The simplest way to get started is to click Add Application in the Application Insights portal, as I mentioned earlier for implementing Usage Monitoring.

Implement Availability Monitoring

Availability Monitoring works for any Web application, regardless of the platform on which it’s running. It only has to be accessible via the Internet. You can test the availability and performance of your Web application from across the world. This module is also the easiest to get working.

When you select the Availability menu within Application Insights, you’ll be prompted to supply the URL for your Web application. This will create a simple URL-based synthetic monitor with a single monitoring location.

If you need to monitor more sophisticated transactions, you’ll probably be better off using a Visual Studio coded Web performance test. The synthetic monitor is based on the same recording functionality commonly used for load testing Web applications. This lets you test a complex set of actions. To create a single URL or multi-step synthetic monitor, click on the green Add new synthetic monitor icon and configure the desired settings (see Figure 5).

Configure the Settings for a New Synthetic Monitor
Figure 5 Configure the Settings for a New Synthetic Monitor

Put Application Insights to Work

Over the last year, nearly 100 internal Microsoft teams and external industry experts tried out early versions of Application Insights and provided feedback as part of a formal Technical Adoption Program. Some of what they uncovered was surprising to the development team, especially the strong interest and engagement by product owners and non-technical team members.

The early adopters agreed a key value of Application Insights is the ability to speed up the development cycle by bringing all this analytics information into a single location in Visual Studio Online.

Measure a Web Campaign One of the first external customers to look at Application Insights was Wintellect—a training and consulting firm. They wanted to understand the impact of course descriptions for their new on-demand training product, WintellectNOW.

Using the Page Views report in Application Insights, Wintellect developers were able to add a JavaScript function to the  Sign Up Now button, similar to this:

function trackCourse()
     window.location.hostname +
     {"CourseID": "Test401"},
     {"RatingValue": 400});

This let them measure and visualize which course descriptions were most effectively driving actual registrations. For more information on implementing custom events in Application Insights, see

Measure Global Web Traffic Wintellect was scheduled to exhibit at TechEd 2013 Europe in Madrid, Spain. The business staff wanted an easy way to measure whether the company’s presence would increase awareness of its offerings in the European market.

The company set up usage reports using Application Insights, and compared the week before TechEd to the week after. Traffic from Europe increased by 7 percent, and it doubled its traffic from Spain. Wintellect didn’t need any special effort by developers to measure these results, so its technical teams were able to stay focused on deliverables.

Streamline Find, Fix and Release

Application Insights is at work at Microsoft as well. The service engineers in charge of the main Microsoft Web site and homepage manage more than 400 applications on a day-to-day basis. Their highest priority is to reduce the time from discovering an issue to getting a fix in place. By setting up dashboards and alerts with Application Insights, they get real-time notification of failing availability tests, performance events or a degrading performance index. This helps the engineers resolve issues before customers even notice anything is wrong.

One team set up an availability monitor with a maximum allowable runtime, with an alert to indicate any time the threshold is crossed. The engineers can then ascertain the cause of failure directly from within the Web view, or download it to Visual Studio and view it as a Web Test Result. The Synthetic Monitors report indicates these tests only started failing after making a deployment. Then it continued running successfully after another deployment. Around four hours later, 11 configuration changes were made. They were able to tie the availability issue directly back to actual code and configuration changes. This helped them diagnose the root cause of the event right away.

With Application Insights, you can optimize your applications before they even generate an alert. In the dashboard, there are Active Alerts, Exception Events, Performance Events, Memory Events, and Performance and Reliability graphs. All these metrics provide easily understandable information for an engineering team looking to improve its applications.

Selecting any of these tiles will take you to the data most likely to lead to an action. For example, clicking on the Performance graph in the Application Insights Dashboard (Figure 6) will take you to the Performance page (Figure 7). In this example, you can see there’s a strong correlation between dependencies, a Web service and response times.

The Application Insights Dashboard
Figure 6 The Application Insights Dashboard

The Application Insights Performance Page
Figure 7 The Application Insights Performance Page

Click on the Memory, Exception or Performance Events tiles in the Dashboard to get to the Events page. Here, you can filter, select, open the memory diagnostics session, start an IntelliTrace debug session or view the changeset that caused the event in Visual Studio.

Wrapping Up

These are just a few examples of how development teams are using Application Insights to work more closely with their operations teams to more quickly deliver better software. You can access Application Insights through Visual Studio Online (

In a future article, I’ll cover integrating cloud-based load testing with Application Insights. For more on creating Web tests, go to For more about Availability Monitoring with Application Insights, go to

With the ease of adding monitoring to your code, the close integration with Visual Studio Online, and the time savings, you’ll definitely want to check out these scenarios and realize what you can accomplish with Application Insights.

Charles Sterling has been at Microsoft for 20 years. Before Microsoft he was a marine biologist working for the United States National Marine Fisheries doing marine mammal research on the Bering Sea. After a six-year tour in Australia as a Microsoft product manager, Sterling is currently back in Redmond as a senior program manager on the Visual Studio development team. Reach him at

Thanks to the following technical experts for reviewing this article:
John Robbins is a co-founder of Wintellect, where he heads up the consulting and debugging services side of the business. He also travels the world teaching his Mastering .NET Debugging and Mastering Windows Debugging courses so that developers everywhere can learn the techniques he uses to solve the nastiest software problems known to man.
Cheryl Hammond is an ALM Consultant and leads the Practices Team at Northwest Cadence, focusing on the ways in which agility, architecture, and test practices improve the lives of developers, strengthen teams, and deliver better software.