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.

Logic App message logging with Azure Functions Application Insights

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

Logic App message logging with Azure Functions Application Insights

  • Click on the newly created Application Insights and navigate to the Properties section to copy the Instrumentation Key

Logic App message logging with Azure Functions Application Insights

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

Logic App message logging with Azure Functions Application Insights

  • Copy the following code to get the Application Insights NuGet Package installed in function App: 
   {
    "frameworks": {
      "net46":{
        "dependencies": {
          "Microsoft.ApplicationInsights": "2.2.0"
        }
      }
    }
  }
  • 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:

Logic App message logging with Azure Functions Application Insights

  • In the next step, create a simple Logic App to send the logging information to Application Insights through the Azure Function.

Logic App message logging with Azure Functions Application Insights

  • 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.

Logic App message logging with Azure Functions Application Insights

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset