As a starting point, I create Logic App 1 that is exposed as a web service and which invokes Logic App 2 in a synchronous way. The second Logic App just puts a request on a Service Bus queue. Once that action is completed, a response is returned and the first Logic App can return a success to the consuming application.
Configure retry policy
Because I want to avoid timeouts because of automatic retries, I update the Call Logic App 2 action, so it will not perform a retry. This is done in the code view. Depending on your use case, you could also limit the number of retries. The minimal time interval between retries is 20 seconds, which is also the default value. This is quite high for a web service scenario, as most clients time out after 60 seconds.
Run an exception scenario
To see what happens in case of an exception, I reconfigure Logic App 2 to send to a non-existing queue. In both Logic Apps, the Response action is skipped because the Logic App stops processing in case of a failure.
Optimize for exceptions
Ensure a meaningful exception is returned
Let's first change the Logic App 2, so it returns the real Service Bus exception in case of a failure. The recommended way, is to add a Scope around the Send Message action. The details of the scope outcome are provided via the @result function. More information is given here. Depending on the resulting outcome of the scope, a different response can be returned.
Remark the Switch statement, based on the status of the scope. The @result function returns an array, that provides a result for each action within the scope. The status of the first action is extracted via this expression: @result('scope')['status'].
In the Failure Response, I return the resulting status code - @result('scope')['outputs']['statusCode'] - and exception message - @result('scope')['outputs']['body']['message'].
Ensure the Logic App continues on failure
Inspect the result
We completely focused on the exception scenario, so it's good to double check that the happy path still behaves well. Just update Logic App 2, to send now to an existing queue. Logic App 2 sends a success response, which is great!
The default settings for retry policies and exception handling might not always fit your scenario. Make sure you understand the Logic Apps capabilities on this matter and apply them according to your needs. Small prototyping exercises can serve as basis for development guidelines and best practices.
Happy exception handling!