Application Insights helps us to track applications health in real time. You can track you application availability, performance issues, users session and diagnose crashes faster then ever. It’s provides a real time dashboard for your app to monitor your application. Let’s have a look how to Create an Application Insights using new Azure Portal and then using it for your Windows Universal App. To start with Application Insight in your Windows Universal app does not even require single line of code, you can just follow the below steps and start tracking your apps telemetry information.
To start with it, Let first learn how to “Create an Application Insight” in Azure Portal .The steps are pretty much simple and easy to followed.
First, Login in to Azure Portal and then navigate to New –> Developer Services –> Application Insights
Then, provide Name of the “Application Insights” and Select the Application Types “Windows Store Application” . You can also change the resource group and location depends on your need. In this case we are not changing it.
Once this is done, click on the “Create” Button. Make sure if you select “Pin to Startboard” checkbox selected, this will ensure you have a quick access icon on the Dashboard.
Once you select “Create” you should be able to see the creation is in process (left ) and then once it’s created successfully, you should be able to see similar tiles (right) in your dashboard.
The details view for your Application Insights would looks like below . All the sections are clickable, you can select them and navigate to details.
That’s all about creation of application insights. You really don’t need to do anything here as of now. Your application insight is ready !
Let’s start creating a new app and see how do we enable the application insight for the app.
Start a new instance of Visual Studio 2015 –> Add New Project –> Select “Blank App (Universal Windows) Template.
In the right side, select the checkbox for “Show telemetry in the Windows Dev Center” and “Enable richer analytics with Application Insights”. When you select this, you will ask for login with your Microsoft Account, and Use the same account for which you have the Azure Subscription and created the Application Insights. Once you are authenticated with your azure account, you should be able to see all your application insight here.
For our demonstration purpose, we will select the “MyWindowsUniversalApp” and then Select “OK”
During the Solution Creation, Visual Studio atomically takes care of all kinds of configuration, code registration and downloading nugget packages.
If you look inside the solution there are few additional components installed and configured to support integration with Application insights.
-
All required Nugget Packages
-
Application Insights Getting started documents
-
Application Insight Config
The Application Configuration files contains the Instrumentation Key, that is mapped to our created Application Insights.
When the applications starts, Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(); is called.
This code Initializes default configuration and starts automatic telemetry collection for application based on the provided Instrumentation Key
That’s all. Your application is ready for send automatic telemetry information. If you run the app, you should be able to see following notification . If you click on the “Open Applications Insights” you would be redirected to the portal.
Just for demo purpose and simulate the app crash add one “Button” in the MainPage.xaml and write following code block on the button click.
Then Run the app and click on the button. Your app will throw an exception.
Let’s open the Azure Portal –> Application Insights Dashboard , You should be able to view all the details of your applications, including the crashes that generated.
You can do further deep down to see the error details.
So far the app was running from the desktop, now if you run the same app in a mobile simulator , you should be able to see multiple devices in the dashboard.
Even you can see which devices causing the maximum of crash through the Application Insights dashboard.
This was just a simple example and but definitely it will get you started with Application Insights and you can then explore more from here..
Hope this helps !
Pingback: Internet of Things (IoT), Mobility, Azure, Universal Windows Platform and Devices – The Daily Developers Links – #3 | Abhijit's World of .NET
Pingback: Visual Studio – Developer Top Ten for August 13th, 2015 - Dmitry Lyalin
Pingback: Using Application Insights right from the Visual Studio 2015
Pingback: How to track Application Insights events from Visual Studio 2015?
Pingback: .NET Tips and Tricks from Daily .NET Tips – ( Visual Studio 2015, Windows Universal Apps, Application Insights, Cross Platform Apps ) – August 2015 Links | Abhijit's World of .NET
Pingback: Using Application Insights for your Android App – with Visual Studio 2015