Azure Logic Apps – How to ‘throw an exception’ in Logic Apps

Hello again 🙂

While I was working away on a Logic App, I came across a situation where I wanted to essentially ‘throw an exception’, and was wondering what the equivalent option in Logic Apps is.

There are two ways you can ‘throw an exception’ in Logic Apps:

1) You can use a ‘Terminate’ action, assuming you want to end your Logic App completely (it will halt execution of the Logic App, and immediately cause the Logic App to ‘Fail’)


2) If you do not want to terminate the Logic App entirely, you can

a) Add a ‘Scope’ block
b) Simulate an ‘exception’ by adding a block inside the ‘Scope’ block that intentionally fails (ie add a ‘Parse JSON’ action where the ‘Content’ does not match the with ‘Schema’ defined, and thus causes the action to fail due to the ‘Content’ not being able to parse properly)
c) You can then handle the ‘exception’ accordingly by using the ‘Configure run after’ option > Add another step after the ‘Scope’ block, and click on the ellipses located to the right of the title of the newly added block, and select the ‘Configure run after’ option. Then select the ‘has failed’ option. Now, the block you have just created will run whenever the ‘Scope’ block fails.

Both of these options allow for a decent way to add exception handling to your Logic App 🙂

Hope this helps! Also, feel free to add comments to this post if needed.



Leave a Reply

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