Muokkaa

Jaa


Test workflows with mock outputs in Azure Logic Apps

Applies to: Azure Logic Apps (Consumption + Standard)

To test your workflow without affecting your production environments, you can set up and return mock outputs, or static results, from your workflow operations. That way, you don't have to call or access your live apps, data, services, or systems. For example, you might want to test different action paths based on various conditions, force errors, provide specific message response bodies, or even try skipping some steps. Setting up mock results from an action doesn't run the operation, but returns the test output instead.

For example, if you set up mock outputs for the Outlook 365 send mail action, Azure Logic Apps just returns the mock outputs that you provided, rather than call Outlook and send an email.

This guide shows how to set up mock outputs for an action in a Consumption or Standard logic app workflow.

Prerequisites

Limitations

  • This capability is available only for actions, not triggers.

  • No option currently exists to dynamically or programmatically enable and disable this capability.

  • No indications exist at the logic app level that this capability is enabled. The following list describes where you can find indications that this capability is enabled:

    • On the action shape, the lower-right corner shows the test beaker icon (Icon for static result).

    • On the action's details pane, on Testing tab, the Static Result option is enabled.

    • In code view, the action's JSON definition includes the following properties in the runtimeConfiguration JSON object:

      "runtimeConfiguration": {
          "staticResult": {
              "name": "{action-name-ordinal}",
              "staticResultOptions": "Enabled"
          }
      }
      
    • In the workflow's run history, the Static Results column appears with the word Enabled next to any run where at least one action has this capability enabled.

Set up mock outputs on an action

  1. In the Azure portal, open your Consumption logic app workflow in the designer.

  2. On the designer, select the action where you want to return mock outputs.

  3. On the action information pane, select Testing, for example:

    Screenshot shows the Azure portal, Consumption workflow designer, HTTP action information pane, and Testing selected.

  4. On the Testing tab, select Enable Static Result.

  5. From the Select Fields list, select the properties where you want to specify mock outputs to return in the action's response.

    The available properties differ based on the selected action type. For example, the HTTP action has the following sections and properties:

    Section or property Required Description
    Status Yes The action status to return.

    - If you select Succeeded, you must also select Outputs from the Select Fields list.

    - If you select Failed, you must also select Error from the Select Fields list.
    Code No The specific code to return for the action
    Error Yes, when the Status is Failed The error message and an optional error code to return
    Output Yes, when the Status is Succeeded The status code, header content, and an optional body to return

    The following example shows when Status is set to Failed, which requires that you select the Error field and provide values for the Error Message and Error Code properties:

    Screenshot shows Consumption workflow and Testing pane after selecting Enable Static Result with the Status and Error fields also selected.

  6. When you're ready, select Save.

    The action's lower-right corner now shows a test beaker icon (Icon for static result), which indicates that you enabled static results.

    Screenshot shows Consumption workflow with HTTP action and static result icon.

    To find workflow runs that use mock outputs, see Find runs that use static results later in this guide.

Find runs that use mock outputs

To find earlier workflow runs where the actions use mock outputs, review that workflow's run history.

  1. In the Azure portal, open your Consumption logic app workflow in the designer.

  2. On your logic app resource menu, select Overview.

  3. Under the Essentials section, select Runs history, if not selected.

  4. In the Runs history table, find the Static Results column.

    Any run that includes actions with mock outputs has the Static Results column set to Enabled, for example:

    Screenshot shows Consumption workflow run history with the Static Results column.

  5. To view the actions in a run that uses mock outputs, select the run where the Static Results column is set to Enabled.

    In the workflow run details pane, actions that use static results show the test beaker icon (Icon for static result), for example:

    Screenshot shows Consumption workflow run history with actions that use static results.

Disable mock outputs

Turning off static results on an action doesn't remove the values from your last setup. So, if you turn on static results again on the same action, you can continue using your previous values.

  1. In the Azure portal, open your logic app workflow in the designer.

  2. Find and select the action where you want to disable mock outputs.

  3. In the action details pane, select the Testing tab.

  4. Select Disable Static Result > Save.

    Screenshot shows logic app workflow, HTTP action, and Testing tab with Disable Static Result selected.

Reference

For more information about this setting in your underlying workflow definitions, see Static results - Schema reference for Workflow Definition Language and runtimeConfiguration.staticResult - Runtime configuration settings.

Next steps