Azure Logic Apps: long run duration
Introduction
Azure Logic Apps is a low-code PaaS solution by Microsoft that features a visual editor to implement business logic. It’s a great way for citizen developers to benefit from Serverless compute in Azure Cloud. It integrates well with other Microsoft technologies and offers tons of Connectors to integrate with 3rd party applications as well.
The problem
Some (or all) Logic App runs have unexpected long durations. In this example we look at the Run history of a Logic App, which shows failed runs having a duration between 5 and 11 minutes.
In this example the runs are failing because the Logic App called an application that was unavailable at that moment, but succeeded runs can also have unexpected long durations.
Troubleshooting
There are 2 possible reasons:
- The combined duration of all the actions in the Logic App is too long
- This often happens if the Logic App makes requests to other systems and those fail. Most actions have a retry policy (an exponential retry policy by default for most operations), those retries can easily add up to multiple minutes. - The Logic App was in waiting state:
- When inspecting a long Logic App run, it’s not always obvious why it took so long; you may see that the actions only take a couple of seconds but the run duration is over 10 minutes. The likely reason is that you have Concurrency Control enabled on the Logic App Trigger.
Concurrency Control
Concurrency Control limits the number of instances that can run simultaneously. Any other triggers will start a Logic App run, but the run is in a waiting state until the number of concurrent runs drops below the limit.
Solution
Reduce combined duration of all actions
Most actions have a retry policy (an exponential retry policy by default for most operations), those retries can easily add up to multiple minutes.
Take a look at all the actions in your Logic App that connect to other applications. Go to the Settings of these actions and change the retry policy in such a way that all the actions together stay within the lock duration of
Disable Concurrency Control
The solution is sometimes as simple as disabling Concurrency Control, but this depends on the situation. If the Logic App makes requests to other systems (either via Connectors or direct HTTP calls) it may create a high load on those other systems. Always evaluate if the dependencies your Logic App connects to are able to handle the potential load.