DEV Community

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

Posted on

6 1 1 1 1

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

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!

Top comments (2)

Collapse
 
wyattdave profile image
david wyatt

Thank you for the mention ❤️

Collapse
 
balagmadhu profile image
Bala Madhusoodhanan

learn a lot from your blog series

👋 Kindness is contagious

Please drop a ❤️ or a friendly comment on this post if it resonated with you!

Okay