Logic App message logging with Azure Functions Application Insights
Application Insights is used to monitor application performance, logging, and detecting and diagnosing exception messages. In this section, we will discuss how we can write messages and logs within Application Insights using Azure Functions and Logic Apps.
We will follow the step-by-step process of creating necessary artifacts for the solution.
Create the Instance of Application Insights in Azure:
To add a new instance of Application Insights Log into Azure portal with the proper Azure subscription. Click on More and add Application Insights
Populate the Application Insights with proper Name, Resource Group, Application Type
Click on the newly created Application Insights and navigate to the Properties section to copy the Instrumentation Key
Add Application Insights to Azure Functions:
Create New function GetmessageLoggingFunApp within Sunny Electricals Azure Function App
Within the Function App, click on Function App Settings and Click on Go to Kuddu
Inside Kuddu, navigate to the newly created function folder and click on add new file and add the project.json file
Copy the following code to get the Application Insights NuGet Package installed in function App:
Click on save to download the Application Insights NuGet Package within the function. You can verify that the NuGet Package update through Function logs.
In the next step, use the reference assembly for the Application Insights within the Function.
Add the following method within the function to create a telemetry client for Application Insights within function:
In the next step, create a simple Logic App to send the logging information to Application Insights through the Azure Function.
Once the Logic App is being triggered, it will send the request and telemetry data to Application Insights. Now Go to Application Insights and verify the logs.