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

What is Application Insights? 

 
Application Insights is a logging tool for both production and development environment workloads which also provides deep information about your Azure application and on-premise environments. It will help to improve application performance with each in & out request.
 

Why?

 
Application Insights (AI) will help us to maintain application-level logging (PaaS) or on-premises(IaaS) trace events from end to end, app performance, page views counts, and more as shown in below. 
  1. Troubleshooting
  2. Performance
  3. Improvement
  4. Trends
  5. Customer Experience
  6. Business Decisions. 
It supports multiple languages like .Net(VB.Net, C#.Net, etc), Java(C++), Java Script,Node.js, Python, Ruby, etc. For more information about supported languages please follow below Url: https://docs.microsoft.com/en-in/azure/azure-monitor/app/platforms
 
It will detect and diagnose issues in your cloud applications and dependencies using Application Insights. It will co-relate your cloud application traces and drill into your issues using log analytics for troubleshooting and diagnosing your application exceptions, performance related issues etc.
 
Below I’m showing a small example about Application Insights using Asp Core. 
 
Learning Series
Prerequisites
  1. Azure Subscription to create azure apps.
  2. Visual studio 2019
  3. SQL Server (Any version) 
Project Information
  1. Web API Core App
  2. MVC Core application
  3. Entity Framework Core
Azure Apps
  1. Azure Resource group
  2. Web Apps - 2
  3. One Application Insights
  4. Free SQL Database server
  5. Azure DevOps to configure CI and CD pipeline.
  6. GIT Hub
I’ll show you the Azure apps required for the below example. if you already  know how to create apps for your project, you can directly shift to the next step.
 
Create a resource group to maintain all Azure app services as environment specific.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Once required fields are filled and it gives validation as shown in the below screenshot, then click on the create button.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
You can click in the resource groups option and click on the refresh button to retrieve your created resource group. Now click on newly created resource group to open.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Now it’s time to create our Azure apps for project setup. Click in the ‘+Add’ option to create new Azure apps.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
It will redirect  to the below screen where you can enter your Azure app information. First create your application insights or azure plan service. In this activityI have a frrr subscription and by default I’ll get a free Azure service plan. So, I directly created application insights and followed the below process.
 
As per the below screen, enter keywords as application insights and click on enter or you can select the filtered option as shown in the below screengrab.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Then action was redirected to the below screenshot and click on the ‘Create’ option to continue. 
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Select your resource group by selecting the drop-down list and provide valid name to your application insights app service. Click on ‘Review + Create’ blue colored button.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Tags option is not required for my example now, so I can skip and I’ll pass the validation for creation.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
The below screen shows us the deployment process for Application Insights and also provides you with the ARM Template information in the templates section.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Now application insights deployment is complete and goes with remaining app services.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Now add 2 more web applications with a free app service plan for an end to end trace logging in application insights.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
New Azure web app creation process for the client-side logging.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Runtime stack in .net core and windows operating system with a free app service plan as shown in the below screengrab.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Now we need to map existing application insights for new app creation. Here I'm trying to show you using application insights mapping to  give a clear picture of components across all components to our distributed applications with flows.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
You can skip this Tags option and Click on 'Next: Review +Create' button for validation.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Validation passed now, click on the 'Create' button.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Once the deployment is complete, click on 'Go to resource' button.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Now repeat the above web app creation process for the remaining web apps.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Now, don't create another new application insights or enable or map existing application insights. Select 'Review + Create' button for the review process.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Validation Passed now, Click on the 'Create' button.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
Now our app services are ready as shown in the below screenshot.
 
Application Insights In MVC Core + Web API Core + Entity Framework Core
 
In Azure Cloud, app services configuration was done and in the next articles, we will  learn about the local environment setup and some practices about Application Insights.