If you work on .NET applications on Azure, you probably might be thinking of how and where you would log information about your application, like telemetry information.
I shared this link to the youtube video that gives a good set of instructions to set this up yourself. There are some things that the video doesn’t cover.
What is application insights?
Application Insights is an extensible application performance management service for developers and DevOps professionals. It will automatically detect performance anomalies and includes analytics tools to help you diagnose issues and understand what users actually do with your app. It is designed to help you continuously improve performance and usability of the app.
It is cross platform, in the sense, it works not only in your .NET apps, but also in your Node.js, Java and Python apps, whether it is on-premises or hybrid or in the cloud anywhere.
How does it work?
In most cases, all you have to do is to install a nuget package in your project, or in some cases, Azure lets you enable application insights for an app that is already running! The instrumentation monitors your app and directs the telemetry data to an Azure application insights resource using a unique GUID that’s called, Instrumentation Key!
Application Insights, not only instruments the main web service application but also any background components and dependencies and even the front end where necessary!
Wherever you push your telemetry information from, you could integrate all of these into Azure Monitor and can apply analytics and search the raw data that is being loged.
This functionality seamlessly integrates into your app, hence performance impacts to your app, is negligible. I say that it is negligible, because there is an impact, however, nothing significant to outweigh the benefits of having it log the performance data.
Why did I write this post when you could find information on Microsoft Docs?
When I inherited a web application, I thought, application insights had to configured by first installing the nuget package and then doing all the setup work behind the scenes, in the Startup.cs and other palces in your application. Little did I know about App Service and how things are different there. If yours is an azure app service, then you can actually turn on the default level of application insights just by using azure portal, without having to deploy any code changes at all. This is known as the codeless, agent-based instrumentation.
However, if you do want to log anything specific, you can always integrate application insights SDK into your app and start doing it yourself.
So do checkout the following links on the docs:
- Application Insights - An Overview
- Application Insights - Platform support - this is where I found a way to turn application insights for my Azure app service. You can apparently do the same for your .net app, your azure functions, and other things.
PS: I have written about Serilog integration with Application insights in another post