Power Automate is a cloud-based tool which plays a vital role in automating workflows and processes within organizations. In Power Automate, the triggers are executed parallelly when multiple requests are created at the same time. In this blog, we will explore how to utilize concurrency control to manage triggers effectively by executing one trigger at a time.
Scenario
Let us take the below scenarios as an example,
- Reading an Excel containing list of users from a SharePoint List.
- Adding them to a SharePoint site collection with predefined permissions.
While this task seems straightforward, it involves making multiple requests simultaneously, which can lead to challenges.
The Flow
To achieve this, I have created a Power Automate flow that reads the excel data and extract user details. It will then loop through each item and add users to the SharePoint site.
In this process of adding users to a SharePoint site, we will be calling the SharePoint Rest APIs in the background. These APIs have limitations and exceeding the defined limits will result in SharePoint throttling error. Consider an example, that 3 requests are created at same time with 1000 user details in each request. If all three requests start at the same time, it will result in SharePoint throttling error which will make the flow to fail.
Concurrency Control
To overcome this, we are going to make the requests to trigger one at a time while the others will be waiting in the queue. Here comes the concept of Concurrency Control, which is a setting in Power Automate trigger or control. It has a feature named ‘Degree of parallelism‘ which varies from 1 to 50. If the value is set to 1, only one flow can run at a time while others will we waiting in the queue.
Setting Degree of Parallelism for a trigger
- Click on the three dots located at the top right of the trigger.
- Select ‘Settings‘.
- In the settings, the Concurrency Control will be turned off by default. Enable it to reveal the ‘Degree of Parallelism’ slider.
- Set the slider value to 1 and click ‘Done’.
5. Now save the flow and trigger multiple requests.
In the below example, we create 4 requests in which only 1 request runs at any given time, while other 3 waits in the queue. Once the running trigger completes its execution, Power Automate will pick the next request in the queue. Please note that the requests do not run in the order in which they are created.
Note:
The triggering of request will not work sequentially. Power Automate will pick up the request which it sees fit and execute.
Conclusion
The parallelism in concurrency control has various purposes. It helps organizations to execute tasks systematically, preventing overloading and ensuring reliability. By queuing requests and running them one at a time, we can avoid issues like throttling and enhance the efficiency of automation process. This can be used in situations where sequence/order of execution is not critical.
No Comment! Be the first one.