Logic Apps: ForEach and Terminate actions

Sometimes the simplest things become hard(er)

Normally it is not a problem terminating the Logic App run by using a Terminate action. But when you are iterating over some kind of list using a “ForEach” action, you are suddenly not allowed to use a “Terminate” action anymore. And Logic Apps does not provide any other way to stop a Logic App run.

But luckily, people has found other ways to make a LogicApps action fail on purpose (where a Terminate is not allowed)
How to throw an exception in Azure Logic Apps

Add a “Compose” action with an illegal int-cast
int(‘__ERROR__’)

or

Using a "SetVariable" action, set an int variable with an illegal string-value
string(‘Exception’)

BTW, these methods does not make the entire Logic App run fail, it only fails the current iteration of the ForEach action – the other iterations continue independently

Discussion of the LogicApps “ForEach” action

LogicApp error

https://stackoverflow.com/a/61101945/42223

Leave a Reply

Your email address will not be published. Required fields are marked *