Application Insights In MVC Core, Web API Core And Entity Framework Core

Introduction 

 
In this article, we learn about Application Insights SDK setup in a local environment using Visual Studio 2019 community edition. It helped to diagnose issues by using Application Insight SDK in visual studio 2019. By using this SDK, we can get collection-level information using application insights telemetry such as to request rates, response times and failure rates, exceptions, etc.
 
Prerequisites
  1. Visual Studio 2019 - Community Edition
  2. Azure SDK
Learning Series
Step 1
 
Right-click on your application and select the ‘Configure Application Insights’ option, as shown in the below screenshot.
 
 
Step 2
 
Select the first option, Application Insights SDK (Local), and click on the ‘Next’ button, as shown in the below screenshot.
 
Application Insights In MVC Core, Web API Core And Entity Framework Core
 
Step 3
 
In the below screenshot, your Application Insights information will be fetched based on your subscription which is mapped with your email id using visual studio 2019. Select your valid Application Insights App service name and click on ‘Next’ for the next process. 
 
If your visual studio is not retrieving your Azure subscription or app services, you need to re-login with your valid login details which are mapped with your Azure subscription service so that it retrieves all your subscriptions and application insights services using Visual Studio 2019.
 
Application Insights In MVC Core, Web API Core And Entity Framework Core
 
Step 4
 
Now it’s re-validate the application insights connection string and click on ‘Next’ for the project dependencies section.
 
Application Insights In MVC Core, Web API Core And Entity Framework Core
 
Step 5
 
Select all checkboxes as shown in the below screenshot and click on the ‘Finish’ button.
 
Application Insights In MVC Core, Web API Core And Entity Framework Core
 
Step 6
 
The configuration process was done and is shown in the below screenshot.
 
Application Insights In MVC Core, Web API Core And Entity Framework Core
 
Step 7
 
Now select ‘View’ option - > goto ‘Other Windows’ -> select Application Insights Search option as shown in the below screenshot.
 
Application Insights In MVC Core, Web API Core And Entity Framework Core
 
Step 8
 
The basic Application Insights dashboard was opened and options available for basic local environments like in the below screenshot.
  1. Application Insights Dashboard tab.
  2. Search option for all types of collection-level logs.
  3. Application Insights Information details.
  4. Time ranges for all collections – Filters for basic visual analytics.
  5. All types of Collections.
Application Insights In MVC Core, Web API Core And Entity Framework Core
 
Step 9
 
Select a custom range and provide from and to dates to retrieve collection level traces.
 
In this section, you’ll get all collection level logs, statistics graphs, more filters which is available in Refine By Section, etc.
  1. Collection Level details separated with count level.
  2. Statistics graph available for selected time ranges, collection-level, etc.
  3. Results in the selected range of information would be very helpful for logging.
  4. Refine Section will help to filter the sections like Requests, Dependencies, request URL.
  5. Stack information will be listed in detail along with execution time, request type, request URL, device type, collection type information, etc. 
Application Insights In MVC Core, Web API Core And Entity Framework Core
 
Step 10
 
The diagnostic tool will provide Process Memory, Events, CPU % for all collections.
  1. In Application insights logging, operation id will play a major role to filter, get logs, collections involved in selected operation id, etc. these type of information very much helps the developer to debug more into the application.
  2. In the below screenshot, the statistics graph for request collection level for a selected particular id.
  3. Stack information in detail.
  4. Refine section.
  5. Search new data with the selected operation ID.
Application Insights In MVC Core, Web API Core And Entity Framework Core
 
Step 11
 
If there are multiple application needs to monitor, you can easily switch to another application insights, shown in the below screengrab.
 
Application Insights In MVC Core, Web API Core And Entity Framework Core
 
Step 12
 
The time range filter option will help to get the last log information within the selected time range options.
 
Application Insights In MVC Core, Web API Core And Entity Framework Core
 
Step 13
  1. Statistics graphs will be separated and presented, which includes collection-level colors.
  2. This is an easy way to get collection-level for selected logs, as shown in the below screenshot.
  3. Request details for selected details.
  4. The collection-level log information would be displayed here.
Application Insights In MVC Core, Web API Core And Entity Framework Core
 
In the next article, we learn how to access application insights app service on the portal level, here.
 
Happy Logging Application Insights In MVC Core, Web API Core And Entity Framework Core