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 the 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 of Application Insights using ASP Core. 

Learning Series

  1. Part 2
  2. Part 3
  3. Part 4

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.

Azure app services

Once the required fields are filled and it gives validation as shown in the below screenshot, then click on the create button.

Required fields

You can click on the resource groups option and click on the refresh button to retrieve your created resource group. Now click on the newly created resource group to open.

Resource groups

Now it’s time to create our Azure apps for project setup. Click on the ‘+Add’ option to create new Azure apps.

Create new Azure apps

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 activity, I have a free 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.

Screengrab

Then action was redirected to the below screenshot and click on the ‘Create’ option to continue.

Create

Select your resource group by selecting the drop-down list and provide the valid name to your application insights app service. Click on the ‘Review + Create’ blue colored button.

Review

The tags option is not required for my example now, so I can skip and I’ll pass the validation for creation.

Validation

The below screen shows us the deployment process for Application Insights and also provides you with the ARM Template information in the templates section.

ARM Template information

Now application insights deployment is complete and goes with the remaining app services.

Deployment

Now add 2 more web applications with a free app service plan for end-to-end trace logging in application insights.

Trace logging

New Azure web app creation process for the client-side logging.

New Azure web

Runtime stack in .net core and Windows operating system with a free app service plan as shown in the below screengrab.

Runtime stack

Now we need to map existing application insights for new app creation. Here I'm trying to show you how to use application insights mapping to give a clear picture of components across all components of our distributed applications with flows.

map existing

You can skip this Tags option and Click on the 'Next: Review Create' button for validation.

Tags option

Validation passed now, click on the 'Create' button.

Validation passed

Arm template

Once the deployment is complete, click on the 'Go to resource' button.

Go to resource

Now repeat the above web app creation process for the remaining web apps.

Web app creation

Now, don't create another new application insight or enable or map existing application insights. Select the 'Review + Create' button for the review process.

Review process

Validation Passed now, Click on the 'Create' button.

Create button

Now our app services are ready as shown in the below screenshot.

Below screenshot

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.


Similar Articles