Cancel running instance of a flow #powerautomate

Power Automate is a powerful tool for efficient business process automation, offering a wide range of connectors to facilitate seamless integration. While configuring flows is typically straightforward, there are cases where it may not be suitable for handling bulk operations or resource-intensive tasks that require processing numerous instances within a limited timeframe. Depending on licensing and organizational structures, flows are subject to limitations on API calls and concurrencies, impacting their ability to handle bulk operations efficiently.

When a flow reaches these limits, it enters a throttled state, causing it to slow down or even halt altogether, preventing further processing of instances. It’s important to note that throttled flow instances do not auto-cancel unless the flow itself is deleted; they remain in a running state. Over time, as the limit restrictions ease, these instances gradually transition to a success state.

To manually cancel these running instances, you can navigate to the flow details page and access the “All runs” page. From there, select the desired running instances and utilize the “Cancel flow run” button to terminate their execution. This allows for more granular control and the ability to manage and resolve any lingering instances that may have been affected by throttling.

There is a limitation to consider: when attempting to cancel flow instances, you can only select 20 instances at a time. This limitation typically works well under normal circumstances. However, we encountered a situation where we had a substantial number of throttled running instances, numbering in the thousands. In such cases, manually selecting and canceling each instance one by one becomes impractical.

Fortunately, there are several approaches to address this challenge:

  1. PowerShell script using PowerApps CLI: You can utilize a PowerShell script combined with the PowerApps CLI to cancel the running instances in bulk.
  2. Custom connector for the Flow API: Another option is to create a custom connector that interacts with the Flow API, allowing you to cancel multiple instances simultaneously.
  3. An alternative approach I explored eliminates the need for additional access or configuration. It involves using another flow to cancel all running instances of the affected flow. This solution leverages HTTP requests with Azure AD authentication as the key to success.

To establish the connection, utilize the following connection information. Replace the “{region}” placeholder with the corresponding region for your environment (e.g., ““).

Base Resource URL:

Azure AD Resource URI:

After a successful sign-in, you can construct the URL with the following format and provide the relative URL as specified below.

URI: /providers/Microsoft.ProcessSimple/environments/{environmentid}/flows/{flowid}/runs?api-version=2016-11-01&$filter=status eq ‘running’

To retrieve data for the first 100 running instances, you can initiate a GET request. You have two options: you can either retrieve the JSON parameter name or utilize a Parse JSON step beforehand to extract the desired data in a structured format. Once you have obtained the necessary data, specify the Cancel Flow Run step to cancel each instance individually.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s