Cuir in eagar

Comhroinn trí


Create cross-environment parameters for workflow inputs in Azure Logic Apps

Applies to: Azure Logic Apps (Consumption + Standard)

In Azure Logic Apps, you can abstract values that might change in workflows across development, test, and production environments by defining parameters. When you use parameters rather than environment-specific variables, you can initially focus more on designing your workflows, and insert your environment-specific variables later.

This article introduces how to create, use, and edit parameters for multitenant Consumption logic app workflows and for single-tenant Standard logic app workflows. You'll also learn how to manage environment variables.

For more information about multitenant and single-tenant Azure Logic Apps, review Single-tenant versus multitenant in Azure Logic Apps.

Prerequisites

Parameters for Consumption versus Standard logic app workflows

For both Consumption and Standard logic app workflows, you can define parameters using the designer. After you define the parameter, you can reference that parameter from any workflow or connection that's in the same logic app resource.

In multitenant Consumption logic app workflows, after you create and use parameters in the designer, you define and set the environment variables in your Azure Resource Manager template (ARM template) and template parameters files. In this scenario, you have to define and set the parameters at deployment, which means that even if you only have to change one variable, you have to redeploy your logic app's ARM template.

In single-tenant Standard logic app workflows, you can work with environment variables both at runtime and deployment by using parameters and app settings. App settings contain global configuration options for all the workflows in the same logic app resource. For more information, review Edit host and app settings for single-tenant based logic apps.

Important

When you have sensitive information, such as connection strings that include usernames and passwords, make sure to use the most secure authentication flow available. For example, in Standard logic app workflows, secure data types, such as securestring and secureobject, aren't supported. Microsoft recommends that you authenticate access to Azure resources with a managed identity when possible, and assign a role that has the least privilege necessary.

If this capability is unavailable, make sure to secure connection strings through other measures, such as Azure Key Vault, which you can use with app settings. You can then directly reference secure strings, such as connection strings and keys. Similar to ARM templates, where you can define environment variables at deployment time, you can define app settings within your logic app workflow definition. You can then capture dynamically generated infrastructure values, such as connection endpoints, storage strings, and more. For more information, see Application types for the Microsoft identity platform.

However, app settings have size limits and can't be referenced from certain areas in Azure Logic Apps. Parameters offer a wider range of use cases than app settings, such as support for large value sizes and complex objects.

For example, if you use Visual Studio Code as your local development tool to run workflows locally, in your logic app project, you can define parameters using the parameters.json file. You can then reference any parameter in this parameters file from any workflow in your project's workflow.json file or from any connection object in your project's connections.json file. The following list describes a couple common use cases:

  • Have a test parameters file that includes all the values that you use during testing. At deployment, you can replace your test parameters file with your production parameters file.

  • Parameterize different parts of your connections.json file. You can then check your connections.json file into source control, and then manage any connections through your parameters.json file.

  • Parameterize complex objects, such as the authentication JSON object. For example, you can replace the authentication object value with a string that holds a single parameters expression, such as @parameters('api-auth').

  • Review and edit the app settings in your project's local.settings.json file. You can then reference these app settings in your parameters.

Note

As a general recommendation, consider using parameters as the default way to parameterize values, not app settings. That way, when you need to store secure keys or strings, you can follow the recommendation to reference app settings from your parameters. If you want, you can use both options in your solution by using parameters to reference app settings.

Define, use, and edit parameters

Azure portal

  1. In the Azure portal, open your logic app workflow. Under Workflows, select and open your workflow in the designer.

  2. From the designer toolbar, select Parameters.

    Screenshot showing Azure portal, designer for Consumption workflow, and "Parameters" on designer toolbar selected.

  3. On the Parameters pane, select Add parameter.

  4. Provide the following information about the parameter to create:

    Property Required Description
    Name Yes The name for the parameter to create.
    Type Yes The data type for the parameter, such as Array, Bool, Float, Int, Object, Secure Object, Secure String, and String.
    Default Value Yes The default value for the parameter. You have to specify the default parameter value because the workflow logic, connection information, and parameter values don't exist in a single location. The designer must be able to resolve the parameter values before loading.

    Important: For the Secure Object and Secure String data types, avoid setting a default value because the value is stored as plain text.
    Actual Value No The actual value for the parameter.

    The following example shows a definition for a string parameter:

    Screenshot showing Azure portal, designer for Consumption workflow, and the "Parameters" pane with an example parameter definition.

  5. If you have more parameters to add, select Add Parameter. Otherwise, close the parameters pane, but make sure to save your workflow to save your new parameter definition.

  6. To reference the parameter from a trigger or action that's in the same workflow, follow these steps:

    1. In the designer, open the workflow that you want, and expand the trigger or action.

    2. In the property where you want to use the parameter, click inside that property's edit box.

    3. From the dynamic content list that opens, under Parameters, select your previously created parameter, for example:

      Screenshot showing designer for Consumption workflow and example action with the cursor in property edit box, expanded dynamic content list, and previously created parameter selected.

  7. To view or edit the parameters in a logic app workflow, follow these steps:

    1. Open the logic app workflow in the designer. On the designer toolbar, select Parameters.

      The Parameters pane opens and displays all the parameters that you defined for that workflow.

    2. Make your edits, close the parameters pane, and save your logic app workflow.