Getting Started with Application Insights with Visual Studio 2015 for your ASP.NET Web Applications
Disclaimer: This post was written 2014-11-13, while the Application Insights were still in Beta/Preview.
Changes will most likely happen, and therefore some information below may have changed by the time you read this.
Introduction to Microsoft Application Insights
One of the really cool features that was recently announced by Microsoft is the Application Insights integration with Visual Studio 2015. Don’t confuse this with reporting provided by services like Google Analytics, which only use client-side reporting capabilities. This is full server-side awesomeness which can report the health of your specific service or application directly, having the reports instantaneously accessible in your Azure Portal.
The mobile projects I’m currently building with Xamarin have a backend hosted with Azure Mobile Services. I’ve used Xamarin Insights for mobile-app insights and reporting to get nice reports and insights in how my apps are behaving and being used. With the recent announcement of the Microsoft Application Insights integration into Visual Studio 2015 (preview), we can now easily add Insights to our Azure Mobile Services projects in order to keep measures on the server-side of your apps as well.
Note: Insights has been around for a while, and if you downloaded an extension for Visual Studio 2013 Update 3, you could add insights to your project as well – now it’s fully integrated into VS 2015, which is awesome.
Application Insights. We released Application Insights first as an extension and then integrated with Visual Studio 2013 in Update 3. We’ve now fully integrated Application Insights into Visual Studio 2015 to make it easy for you to add monitoring to your projects and we’ve smoothed the workflow to publish to an Azure website. Visit the Azure website to get started and learn more about Application Insights.
– Visual Studio Team Blog
Adding Application Insights to your Visual Studio 2015 project
Let’s get started with the technical details directly here. We really want to dig into how we can add insights into our existing or new projects, so here’s a step-by-step guide for doing so.
Add Application Insights to a new ASP.NET project
If you’re creating a new Visual Studio 2015 project make sure to tick the “Add Application Insights to Project” checkbox in the Create-dialog, as seen in this screenshot:
[
{ throw new Exception("Oh noes, the application went boom"); } ```
Launch your application and make sure to navigate around a bit, posting various requests. In my sample I’ve got the BtnFail (as seen above) which will simply throw an exception. I’ve clicked that a few times for this demo.
See your Application Insights, live while debugging
From Visual Studio 2015 you can choose to view Application Insights from the toolbar and also configure if you want to see notifications:
[ and what type of failed request it was (in my case an Exception).
Here, I’ve clicked the System.Web.HttpUnhandledException row just to drill down into that data:
[ in your applications. Not only can you easily add this to new web applications, it’s also very easy to add into existing applications.
If you are running Visual Studio 2013, there’s an extension you can download which handles Application Insights for you, but with Visual Studio 2015 this is fully integrated.