Having deployed an application to Azure, you would want to track how the application is performing, how are they used and know the appliation issues. Microsoft Azure’s Application Insights allows you to monitor both the health and usage of your web application. So we have usage analysis, monitor availability and performance tracking. This article focus on how to enable your application with Aplication Insights.
There are several ways to integrate Application Insigts to your application. In this article, we will look the in-built way of enabling it from Visual Studio (requires re-publishing your application to Windows Azure for existing applications)
Prerequisites: (1) A Windows Azure account (2) Visual Studio 2013 or 2015 (3) This article also assumes that you have an application that is already deployed or ready to deploy to Windows Azure.
Create an Application Insights resource in your Azure account.
Go to Azure portal. Add new resource and select ‘Application Insights’. Choose application type as ASP.NET in the configuration window.
Once created, you can find the ‘Instrumentation Key’ generated for the AI resource. We will discuss about the use of it in a while.
Add Application Insights SDK to your Web Application using Visual Studio
Scenario -1 : If you are creating a new project, the options for integrating the ‘application insights’ are available in the ‘New Project’ dialog as below.
Note that, since I have logged in to my Azure account, I am able to select the exising AI resource that I created in the previous step. Nevertheless, you can create a new one for your application if you wish to and it gets created in your Azure Account.
Scenario -2 : If you you have an existing project and you want to enable Application Instigts and deploy to Azure, right click the project and choose ‘Configure Application Insights’ as shown below.
Log in to your Azure account and it provides you same options to choose or create Application Insights resource.
The required resources will be added to your project; let us look into the added resources:
- This is where we customize the telemetry components such as dependency tracking, performance counters etc. This configuration file gets added and note that your instrumentation key has been automatically pulled from Azure and added to this configuration file.
Publish Your Application to Azure
This is straightforward. Publish your application to Azure and your AI configurations along with your application will be deployed to Azure and ready to collect the instrumentation data.
When it is time to pull some metrics, go to your Application Insights resource in Azure portal, select the resource and view ‘Performance’
Another example below; reviewing the failures.