Catching Exception Details in Azure Logic Apps Action Group
Image Source:
Developer Tools
Sep 28, 2023 7:27 AM

Catching Exception Details in Azure Logic Apps Action Group

by HubSite 365 about Stefano Demiliani [MVP]

Citizen DeveloperDeveloper ToolsM365 Hot News

Improve your serverless workflows with Azure Logic Apps! Learn how to handle exceptions, retrieve details, and implement error logging for efficiency.

Azure Logic Apps: Exception Details in a Flow

Azure Logic Apps, alongside Power Automate, enable execution of particular actions based on the status of a previous group of actions, grouped inside a 'scope'. Organizing actions as logical groups lets developers gauge the group's status, enabling actions based largely on the scope's status. A status is given to the 'scope' once the completion of each included action.

Using a 'scope' is paramount when constructing intricate workflows. The use of scopes permits error handling in cloud workflows, similar to a Try-Catch approach in C#. In attempting to implement an efficient error handling with scopes, it becomes convenient to group together actions in a cloud workflow. With an occurrence of an action failure, retrieving the error detail becomes crucial for further debugging or rerouting error details to other systems, artificially included in the actions of an email message, a Teams message, or Application Insights logging.

Developer Tools

In the example provided, the use of Azure Logic Apps sends an HTTP request to an external endpoint. With successful perceptions, the response message, along with the HTTP status, is retrieved paving way for further actions to be executed. All these steps are recognized as part of the same 'scope'.

Notably, when an action failure occurs inside the primary scope, retrieving the failing action, the exception thrown, and saving the error details is possible for further actions with those details. The adoption of the 'exception handling' pattern is defined using scopes. The underlying 'Catch' scope is configured to run after specific conditions as follows:

Subsequently, the 'Catch block' is only activated when the 'Try block' notices a failure, triggered by a skipped block, or a block that has timed out. In an intentionally designed exception, an HTTP call is placed to an external endpoint that does not exist. On 'Try block’ failure, a JSON body (JSON array) with details of the action status is sent to the 'Catch block'.

Working With Exception Details

To isolate exception details, the 'Catch block' employs the Filter Array action to acquire the message of the exception sent by the Scope action. Only the item where status equals 'Failed' (the action causing the exception) is of interest here. These acquired details can then be assigned to a variable called 'Exception', where the exception is understood for further use (for example, in an email, a Teams message, or logging purposes).

Should the workflow be triggered, the HTTP action within the 'Try block' fails causing the execution of the 'Catch block'. With the filter array receiving the JSON body of actions from the initial scope as input, the resulting output is a filtered JSON providing details only on the action that has failed.

Finally, the message details of the error is retrieved and assigned to the 'exception variable' for ongoing processing. Thus, the serverless workflow now implements a robust exception handling system. For complex workflows requiring extensive monitoring, implementation of this pattern is highly recommended for efficient exception handling and logging.

Read the full article Azure Logic Apps: retrieving the exception details of an action group in a flow

Developer Tools - Catching Exception Details in Azure Logic Apps Action Group

Learn about Azure Logic Apps: retrieving the exception details of an action group in a flow

Developing effective cloud-based workflows requires solid skills in manipulating Azure Logic Apps, a Microsoft cloud service used for automating business processes and building complex integration solutions. In this blog post, we walk you through the steps of retrieving exception details from an action group in Azure Logic Apps— a key measure in error handling, group evaluation, and improved exception handling.

The use of the scope action in Azure Logic Apps (and Power Automate) is necessary when creating intricate workflows. It allows one to group specific actions together. Once all the actions within a scope finish running, the scope acquires its own status.

'Scopes' enable a group of actions to run only if another group of previous actions succeed or fail. It's tremendously effective when organizing actions logically. When an action within the scope doesn't succeed, the details constituting the specifics of the error can be logged or sent to other systems for further analysis.

For instance, a workflow can be established to handle HTTP requests to an external endpoint. If the request succeeds, the HTTP status and response message are retrieved, and other actions are then executed within the same scope. This level of control allows for actions within the main scope that fail to be logged, and the results processed further.

Emphasizing on how scopes work ensures a clear understanding. Consider a scope containing actions referred to as 'Try', and a second scope called 'Catch.' Now, a misstep in the 'Try' block will only cause the 'Catch' block to execute if the 'Try' block fails, is skipped, or times out.

The actions in the 'Catch' block are defined based on the exception details returned by the 'Scope' action. Using the 'Filter array' action, a JSON array's items can be filtered to retrieve only the action where the status equals 'Failed'.

To truly appreciate the potential of scopes in Azure Logic Apps, we'll need to explore defining formulas, filtering JSON arrays and, ultimately, error handling. While this might seem complex at first, the process becomes more manageable as you become familiar with it.

The concluded process results in the exception detail being assigned to a variable called 'Exception', which you can then tailor as per your needs. From email messages, custom logging, to Teams messages, the possibilities are numerous.

Consider a scenario where one of your actions doesn't execute correctly, perhaps due to the HTTP request to an external endpoint failing. The 'Catch' block actions are executed, and the 'Filter array' action inputs the JSON body of actions from the first scope, returning a filtered JSON with details of the action that failed.

Remember that the focus is on improving exception handling and logging. Ultimately, you get a comprehensive mechanism for exceptional handling in your serverless workflow, thereby, enhancing not only your workflows but also the monitoring and handling exception handling process.

For those fascinated by cloud-based workflows, and wish to advance their skills in this field, more thorough knowledge and experience in Microsoft Developer Tools is a must-have. Several courses offer specialized training, such as Microsoft's own certification programs, or other providers such as Edx and Coursera.

With the dynamic nature of the IT industry, keeping abreast with Azure Logic Apps will provide a significant edge in the market. As you continually explore the capabilities of Azure Logic Apps, remember that practice makes perfect. Happy learning!

More links on about Azure Logic Apps: retrieving the exception details of an action group in a flow

Azure Logic Apps: retrieving the exception details of an ...
Feb 28, 2023 — When I have a cloud workflow, I love grouping actions together and when an action fails, I often want to retrieve the error detail and log it or ...
Handle errors and exceptions in Azure Logic Apps
Feb 17, 2023 — In the Azure portal, open the logic app workflow in the designer. On the designer, select the action shape. On the details pane, select Run ...
Azure Logic Apps: retrieving the exception details of an acti...
Mar 1, 2023 — When I have a cloud workflow, I love grouping actions together and when an action fails, I often want to retrieve the error detail and log it or ...


Azure Logic Apps, Exception Details, Action Group, Flow, Retrieve Exception, Azure Flow, Logic Apps Error, Action Group Error, Azure App Exception, Flow Exception Details