Azure Application Insights Configuration for Function App running locally
Today, I will show how to configure Azure Application Insights while developing the function locally. And where to configure the same after deploying in Azure.
What we need?
Access to Azure Portal, if you don’t have , don’t worry , you can create a Sanbox with Microsoft Learn to perform the same and VS2019.
Steps:
- Create a Resource Group
- Create a Application Insights Instance under that resource group and provide location for this instance.
- Open VS 2019.
- Create a new Project of Type Function App.
- By default, it will create a Function app named Function1, keep it as it is.
- There will be two files,
a. one is host.json, which is responsible for global configurations for our function apps.
b. another is local.settings.json, it is responsible for storing our local development related settings. i.e. Azure Storage Emulator if we don’t want to use Azure Storage, this file is critical for configuring Application Insights. Please do remember that this file will be ignored when we will do a release in Azure.
7. Configure your logging level in host.json, please follow below snippet,
8. In your local.settings.json, you can configure Application Instrument Key, so that logs and metrics will be sent to Application Insights on Azure. Please find the below code snippet for your reference.
9. Now Run your application and you are done. Now all your application telemetry will be pushed to Azure, you can see your telemetry data as below,
10. When deploying the app in Azure, you can set the App Insight Key by making changes in Application Settings, as below
If any clarifications are required , please feel free to get in touch with me and always refer Microsoft Learn Documentation.
In Application Insights Log tables you can find according to below categories,