Introduction
In this article, we are going to discuss Application Insights and how to integrate Application Insight into the Azure Function app. We will also create a simple Azure function app and log data into application insights.
If you are new to Azure functions then first check the below articles,
- How To Create And Publish Azure Function From Visual Studio
- How To Easily Create Azure Functions Using Azure Portal
- How to Integrate Dependency Injection In Azure Functions
In this article, we will cover the below topics,
- What is Application Insights?
- Enable Application Insight at the time of creating Function App
- Integrate Application Insight into Existing Function App
- Log data from Azure Functions into Application Insights
What is Application Insights?
When creating a Cloud application or on-prem application, monitoring always helps us to quickly analyze and debug any issue. Azure Monitor is a service provided by Azure to monitor, analyze, and improve the availability and performance of your application.
According to Microsoft Docs,
Application Insights, a feature of Azure Monitor, is an extensible Application Performance Management (APM) service for developers and DevOps professionals. Use it to monitor your live applications. It will automatically detect performance anomalies and include powerful analytics tools to help you diagnose issues and understand what users actually do with your app.
Application insights collect telemetry data from connected apps and provide Live Metrics, Log Analytics, etc. Application insights have an instrumentation key which we need to configure into our function app i.e. APPINSIGHTS_INSTRUMENTATIONKEY and with this key app insights grab data from our app. We can integrate application insights into Azure function in multiple ways as below,
Prerequisites
- Azure account (If you don't have an Azure subscription, create a free trial account)
Enable Application Insight at the time of creating Function App
When we create a function app and also create application insights along with that then the instrumentation key is already set up in application settings with the name APPINSIGHTS_INSTRUMENTATIONKEY
- Log in to the Azure portal. In the Search bar, search "function app" and then select the Function app.


- After that click on the "Add" button to add a new function app. Fill out the basic details,

- Once we fill out the basic details, then click on the Next: Hosting button.

- Once we fill out the hosting details then click on the Next: Monitoring button.

- So here we can enable the application insight for our function app. By default, it takes the same name as the function name but if you want to give a custom name then click on the "Create new" button and then enter the name for insight & also you can select a preferred location.

- Now click on the Review: Create button review all the details and click on the Create button. Wait for a few minutes to create the resources.
- Open the function app -> click on Application Insight from the left pane. You will see that our app insight is now linked to the function app.

- Open the application insight and you can verify the Instrumentation Key here.

- Go to Configuration to see that Azure automatically added APPINSIGHTS_INSTRUMENTATIONKEY into our function app.












Hamid KhanPosted Jan 21, 2021, 5:29 PM
Very good explanation.......@Sumit