How can I handle exception in Azure Logic App

3.2k Views Asked by At

I'm using Azure Logic App. This is the architecture:

Insert Row

I have a Scope Insert Row that include an insert statement in database. I would like to send via mail the message of the exception of the insertion. For example if the Insert statement failed with Foreign key exception, i would like to send this message.

How can I refer to this error message inside the 'Send error Msg' feature?

Thanks a lot guys :)

2

There are 2 best solutions below

4
On BEST ANSWER

You could set the Configure run after value to implement it. Set the Send an email action run after Insert row has failed.

enter image description here

enter image description here

If the Insert action success, the send mail won't execute and if it fails the send mail would work. You could also add the run after action value like the time out or is skipped, they are all kind of exceptions.

enter image description here

enter image description here

UPDATE: If this is your error message, you could add it with @{body('Insert_row')?['message']} in code view mode.

And here is my error message and the subject setting.

enter image description here

enter image description here

enter image description here

enter image description here

0
On

You can make use of Filter Array and result function to capture the actual error of an action failed in a Scope.

For more insights with example see following article - How can I handle exception in Azure Logic App

Thanks, Maheshkumar Tiwari TechFindings...by Maheshkumar Tiwari