From Automation to Insight: Logging Errors with Power Automate and AppInsight
Bala Madhusoodhanan

Bala Madhusoodhanan @balagmadhu

About: - Curious Learner for Supply chain Domain, Sustainability, Machine Learning, RPA - Fostering innovation and exploring opportunities to drive efficiencies

Location:
Aylesbury, United Kingdom
Joined:
Oct 11, 2022

From Automation to Insight: Logging Errors with Power Automate and AppInsight

Publish Date: Apr 28
8 2

Intro:
With lot of automation adoption with power automate efficient error logging is crucial for maintaining robust and reliable applications.

Some of the cool resource I recommend shared by @wyattdave

1) how to create Appinsight logging for Power Apps - PowerApplink
2) power-automate-flow-logging- PowerAutomateLink

But what if I just want to log for a particular automation ? This article explores how to leverage Power Automate to log errors into AppInsight seamlessly. By integrating these powerful tools, you can gain real-time insights into your application's performance, swiftly identify issues, and ensure smooth operations.

Setup:
The setup i did was to have a "Manually trigger a flow" as a trigger and add a HTTP post action.

Configure the HTTP action with the following details as below

Verify URI: Confirm that the URI https://dc.services.visualstudio.com/v2/track*

Check Headers: Ensure that the headers are correctly formatted and include "Content-Type": "application/json".

Image description

Here is the paylod that i had leveraged. Just change the API Key: Make sure to replace "xxxxxxxx-xxxxxxxx-xxx-xxxxxxxxxxx" with your actual AppInsight instrumentation key.

{
  "name": "CustomEvent",
  "time": "@{utcNow()}",
  "iKey": "xxxxxxxx-xxxxxxxx-xxx-xxxxxxxxxxx",
  "data": {
    "baseType": "EventData",
    "baseData": {
      "ver": 2,
      "name": "This is a Dummy Test Message",
      "properties": {
        "Alert Type": "INFO / ERROR / WARNING",
        "Created On": "@{utcnow()}",
        "Flow Name": "testAppInsight",
        "Additional info": "this is a dummy message template"
      }
    }
  }
}

Enter fullscreen mode Exit fullscreen mode

Once you run the flow, you could navigate to Appinsight and look at the custom event table.

Image description

The HTTP post action as part of your critical power automate cloud flows will enable robust error logging system. Happy logging!

Comments 2 total

Add comment