Managing Power Automate Flow Failures
We’re back with another post in our new, learning-focused series on Business Intelligence and Automation. If you missed the first post from RedCloud experts Benny Swedberg (Practice Lead - Business Solutions and Intelligence) and Yusuf Shariff (Power Platform Senior Associate), head here to read their Embedded Galleries techniques. Be sure to let us know if you want a particular topic covered so we can ask Benny and Yusuf to share their wisdom! Without further adieu, here are their latest and greatest tips for managing Power Automate flow failures.
Managing Power Automate Flow Failures
Power Automate provides a number of ways to monitor cloud flow activity. There are periodic emails sent to flow owners notifying them of recent failures, and there is also the Cloud flow activity dashboard. However, we have found that when operating business critical flows, we need to be far more responsive when a flow fails.
As a result, our Power Automate team at RedCloud has developed a method to quickly and easily log flow failures and notify the flow owner. Admittedly, there are gaps, which I will address later, but this method has greatly improved our responsiveness to failures and identification of core issues.
Setting the table
Perhaps we have a simple flow that retrieves SharePoint items on a schedule and sends one reminder email.
We also want to be immediately notified when the flow fails. To do that, we start creating a Scope to encapsulate the flow failure logging actions. This also makes it incredibly easy to copy and paste across flows.
More critically, we need to set the Log flow failure scope to only run when there is a failure. You do this by changing the scope’s Configure run after settings. By default, all actions run after the previous action ‘is successful’. In our case, we want the scope to run when the prior action ‘has failed’, ‘is skipped’, or ‘has timed out’.
These three outcomes cover scenarios such as these:
- Has failed: the scope will run if the previous action has failed
- Is skipped: the scope will run if the previous action was skipped because a prior action failed. For example, the ‘Get items’ step failed and the ‘Send email’ action was never initiated. - Has timed out: the scope will run if the prior action timed out. This commonly occurs when an approval is not completed within 30 days.
Ther are times when you may only want the Log flow failure scope to run after the previous action has failed, so use your own business case to set the run after settings.
Getting workflow details
Now that the scope will run when desired, we need to capture critical flow run details. There is a handy flow expression called workflow().
As you will see, the output provides flow run details that allow you to generate the link to the particular run! The critical values I have underlined.
"/subscriptions/de199c31-4f16-4099-87e6-0b5042c8bada/resourceGroups/F24185AE9B1C4 DAA8E323BC7BA68B0C3-0845F0C2652041ED9E6FB4FCDBA1C2D0/providers/Microsoft.Logic/wo rkflows/5c215c10-fe2e-46e6-a79a-8e8f4d77ed06",
"flowDisplayName": "Demo Flow Failure Log",
"environmentName": "Default-f24185ae-9b1c-4daa-8e32-3bc7ba68b0c3", "logicAppName": "5c215c10-fe2e-46e6-a79a-8e8f4d77ed06",
Now we can generate a flow run url from the following format:
With another simple compose set, we have the flow run url then be logged and enable the owner to quickly access the run!
From there, all that is needed is logging the failure into a centralized list. There are numerous data sources you could use, and we have used a few of them. In some cases, we use a simple SharePoint list. In others we log a bug in Azure DevOps or create a record in Dataverse. What is nice about DevOps is that it automatically notifies the bug owner that it has been created. Alternatively, you could create a flow that sends a notification when the failure is logged in a SharePoint list.
Unfortunately, creating this log flow failure function will then mark a run that fails as a success in the log. This may be okay with you, but if you want those runs to be accurately marked as a failure, I suggest then adding a terminate step within the scope.
With all of this done, you now have a simple method:
a. Generate a flow run url by using the workflow() function and doing so only when a flow fails according to your criteria
b. Log failures for immediate action
c. Create a failure log to analyze and find trends
Let us know what other methods you and your team have used to manage flows!
Comments are closed.