有关 Azure 逻辑应用中触发器和操作类型的架构参考指南Schema reference guide for trigger and action types in Azure Logic Apps

本参考文档介绍用于在逻辑应用的基础工作流定义(由工作流定义语言描述和验证)中标识触发器和操作的通用类型。This reference describes the general types used for identifying triggers and actions in your logic app's underlying workflow definition, which is described and validated by the Workflow Definition Language. 若要查找可在逻辑应用中使用的特定连接器触发器和操作,请参阅连接器概述中的列表。To find specific connector triggers and actions that you can use in your logic apps, see the list under the Connectors overview.

触发器概述Triggers overview

每个工作流包含一个触发器,该触发器定义了可以实例化并启动该工作流的调用。Every workflow includes a trigger, which defines the calls that instantiate and start the workflow. 以下为常规触发器类型:Here are the general trigger categories:

  • 轮询触发器 - 定期检查服务的终结点A polling trigger, which checks a service's endpoint at regular intervals

  • 推送触发器 - 创建终结点的订阅并提供回叫 URL,以便该终结点可在发生指定事件或数据可用时通知触发器 。A push trigger, which creates a subscription to an endpoint and provides a callback URL so the endpoint can notify the trigger when the specified event happens or data is available. 然后触发器等待终结点的响应,接着才触发。The trigger then waits for the endpoint's response before firing.

触发器都具有以下顶级元素,但有一些是可选元素:Triggers have these top-level elements, although some are optional:

"<trigger-name>": {
   "type": "<trigger-type>",
   "inputs": { "<trigger-inputs>" },
   "recurrence": { 
      "frequency": "<time-unit>",
      "interval": <number-of-time-units>
   },
   "conditions": [ "<array-with-conditions>" ],
   "runtimeConfiguration": { "<runtime-config-options>" },
   "splitOn": "<splitOn-expression>",
   "operationOptions": "<operation-option>"
},

必需Required

ValueValue 类型Type 说明Description
<trigger-name><trigger-name> StringString 触发器的名称The name for the trigger
<trigger-type><trigger-type> StringString 触发器类型,例如“Http”或“ApiConnection”The trigger type such as "Http" or "ApiConnection"
<trigger-inputs><trigger-inputs> JSON 对象JSON Object 定义触发器行为的输入The inputs that define the trigger's behavior
<time-unit><time-unit> StringString 用于描述触发器触发频率的时间单位:“秒”、“分钟”、“小时”、“天”、“周”、“月”The unit of time that describes how often the trigger fires: "Second", "Minute", "Hour", "Day", "Week", "Month"
<number-of-time-units><number-of-time-units> IntegerInteger 指定触发器触发频率的值,即触发器再次触发之前需等待的时间单位数A value that specifies how often the trigger fires based on the frequency, which is the number of time units to wait until the trigger fires again

下面是最小和最大间隔:Here are the minimum and maximum intervals:

- 月:1-16 个月- Month: 1-16 months
- 天:1-500 天- Day: 1-500 days
- 小时:1-12,000 小时- Hour: 1-12,000 hours
- 分钟:1-72,000 分钟- Minute: 1-72,000 minutes
- 秒:1-9,999,999 秒- Second: 1-9,999,999 seconds

例如,如果间隔为 6,频率为“月”,则重复周期为每 6 个月。For example, if the interval is 6, and the frequency is "Month", the recurrence is every 6 months.

可选Optional

ValueValue 类型Type 说明Description
<array-with-conditions><array-with-conditions> ArrayArray 数组,其中包含一个或多个决定是否运行工作流的条件An array that contains one or more conditions that determine whether to run the workflow. 仅适用于触发器。Available only for triggers.
<runtime-config-options> JSON 对象JSON Object 通过设置 runtimeConfiguration 属性可更改触发器运行时行为。You can change trigger runtime behavior by setting runtimeConfiguration properties. 有关详细信息,请参阅运行时配置设置For more information, see Runtime configuration settings.
<splitOn-expression> StringString 对于返回数组的触发器,可指定一个将数组项拆分或解除批处理到多个工作流实例进行处理的表达式For triggers that return an array, you can specify an expression that splits or debatches array items into multiple workflow instances for processing.
<operation-option> StringString 通过设置 operationOptions 属性可更改默认行为。You can change the default behavior by setting the operationOptions property. 有关详细信息,请参阅操作选项For more information, see Operation options.

触发器类型列表Trigger types list

每个触发器类型用于定义其行为的接口和输入不同。Each trigger type has a different interface and inputs that define the trigger's behavior.

内置触发器Built-in triggers

触发器类型Trigger type 说明Description
HTTPHTTP 检查或轮询任何终结点。Checks or polls any endpoint. 此终结点必须使用 202 异步模式或返回一个数组,以符合特定的触发约定。This endpoint must conform to a specific trigger contract either by using a 202 asynchronous pattern or by returning an array.
HTTPWebhookHTTPWebhook 为逻辑应用创建一个可调用的终结点,但调用指定的 URL 来注册或注销。Creates a callable endpoint for your logic app but calls the specified URL to register or unregister.
RecurrenceRecurrence 根据定义的计划执行。Fires based on a defined schedule. 可以设置在将来某个日期和时间执行此触发器。You can set a future date and time for firing this trigger. 根据频率,还可指定运行工作流的次数和天数。Based on the frequency, you can also specify times and days for running your workflow.
RequestRequest 为逻辑应用创建一个可调用的终结点,此类触发器也称为“手动”触发器。Creates a callable endpoint for your logic app and is also known as a "manual" trigger. 相关示例请参阅使用 HTTP 终结点调用、触发或嵌套工作流For example, see Call, trigger, or nest workflows with HTTP endpoints.

托管的 API 触发器Managed API triggers

触发器类型Trigger type 说明Description
ApiConnectionApiConnection 使用 Azure 托管 API 检查或轮询终结点。Checks or polls an endpoint by using Azure-managed APIs.
ApiConnectionWebhookApiConnectionWebhook 通过调用 Azure 托管 API 为逻辑应用创建可调用的终结点,以便执行订阅和取消订阅操作。Creates a callable endpoint for your logic app by calling Azure-managed APIs to subscribe and unsubscribe.

触发器 - 详细参考Triggers - Detailed reference

APIConnection 触发器APIConnection trigger

此触发器使用 Azure 托管 API 检查或轮询终结点,因此,此触发器的参数可能因终结点而异。This trigger checks or polls an endpoint by using Azure-managed APIs so the parameters for this trigger can differ based on the endpoint. 此触发器定义中的许多部分是可选的。Many sections in this trigger definition are optional. 触发器的行为取决于是否包含部分。The trigger's behavior depends on whether or not sections are included.

"<APIConnection_trigger_name>": {
   "type": "ApiConnection",
   "inputs": {
      "host": {
         "connection": {
            "name": "@parameters('$connections')['<connection-name>']['connectionId']"
         }
      },
      "method": "<method-type>",
      "path": "/<api-operation>",
      "retryPolicy": { "<retry-behavior>" },
      "queries": { "<query-parameters>" }
   },
   "recurrence": { 
      "frequency": "<time-unit>",
      "interval": <number-of-time-units>
   },
   "runtimeConfiguration": {
      "concurrency": {
         "runs": <max-runs>,
         "maximumWaitingRuns": <max-runs-queue>
      }
   },
   "splitOn": "<splitOn-expression>",
   "operationOptions": "<operation-option>"
}

必需Required

ValueValue 类型Type 说明Description
<APIConnection_trigger_name><APIConnection_trigger_name> StringString 触发器的名称The name for the trigger
<connection-name><connection-name> StringString 工作流使用的托管 API 连接的名称The name for the connection to the managed API that the workflow uses
<method-type> StringString 与托管 API 通信的 HTTP 方法:“GET”、“PUT”、“POST”、“PATCH”、“DELETE”The HTTP method for communicating with the managed API: "GET", "PUT", "POST", "PATCH", "DELETE"
<api-operation> StringString 要调用的 API 操作The API operation to call
<time-unit><time-unit> StringString 用于描述触发器触发频率的时间单位:“秒”、“分钟”、“小时”、“天”、“周”、“月”The unit of time that describes how often the trigger fires: "Second", "Minute", "Hour", "Day", "Week", "Month"
<number-of-time-units><number-of-time-units> IntegerInteger 指定触发器触发频率的值,即触发器再次触发之前需等待的时间单位数A value that specifies how often the trigger fires based on the frequency, which is the number of time units to wait until the trigger fires again

下面是最小和最大间隔:Here are the minimum and maximum intervals:

- 月:1-16 个月- Month: 1-16 months
- 天:1-500 天- Day: 1-500 days
- 小时:1-12,000 小时- Hour: 1-12,000 hours
- 分钟:1-72,000 分钟- Minute: 1-72,000 minutes
- 秒:1-9,999,999 秒- Second: 1-9,999,999 seconds

例如,如果间隔为 6,频率为“月”,则重复周期为每 6 个月。For example, if the interval is 6, and the frequency is "Month", the recurrence is every 6 months.

可选Optional

ValueValue 类型Type 说明Description
<retry-behavior> JSON 对象JSON Object 自定义状态代码为 408、429 和 5XX 的间歇性故障以及任何连接异常的重试行为。Customizes the retry behavior for intermittent failures, which have the 408, 429, and 5XX status code, and any connectivity exceptions. 有关详细信息,请参阅重试策略For more information, see Retry policies.
<query-parameters> JSON 对象JSON Object 要包括在 API 调用中的任何查询参数。Any query parameters to include with the API call. 例如,"queries": { "api-version": "2018-01-01" } 对象将 ?api-version=2018-01-01 添加到调用。For example, the "queries": { "api-version": "2018-01-01" } object adds ?api-version=2018-01-01 to the call.
<max-runs> IntegerInteger 默认情况下,工作流实例将同时(并发或并行)运行,直到达到默认限制By default, workflow instances run at the same time (concurrently or in parallel) up to the default limit. 若要通过设置新的 值更改此限制,请参阅更改触发器并发To change this limit by setting a new <count> value, see Change trigger concurrency.
<max-runs-queue> IntegerInteger 当工作流已运行最大数量的实例(可基于 runtimeConfiguration.concurrency.runs 属性进行更改)时,任何新运行的实例都会被放入此队列(最多达到默认限制)。When your workflow is already running the maximum number of instances, which you can change based on the runtimeConfiguration.concurrency.runs property, any new runs are put into this queue up to the default limit. 若要更改此默认限制,请参阅更改等待的运行限制To change the default limit, see Change waiting runs limit.
<splitOn-expression> StringString 对于返回数组的触发器,此表达式引用要使用的数组,从而可为每个数组项创建和运行一个工作流实例,而不是使用“for each”循环。For triggers that return arrays, this expression references the array to use so that you can create and run a workflow instance for each array item, rather than use a "for each" loop.

例如,此表达式表示触发器正文内容中返回的数组中的某一项:@triggerbody()?['value']For example, this expression represents an item in the array returned within the trigger's body content: @triggerbody()?['value']

<operation-option> StringString 通过设置 operationOptions 属性可更改默认行为。You can change the default behavior by setting the operationOptions property. 有关详细信息,请参阅操作选项For more information, see Operation options.

输出Outputs

元素Element 类型Type 说明Description
headersheaders JSON 对象JSON Object 响应的标头The headers from the response
bodybody JSON 对象JSON Object 响应的正文The body from the response
状态代码status code IntegerInteger 响应中的状态代码The status code from the response

示例Example

此触发器定义每天检查 Office 365 Outlook 帐户收件箱中的电子邮件:This trigger definition checks for email every day inside the inbox for an Office 365 Outlook account:

"When_a_new_email_arrives": {
   "type": "ApiConnection",
   "inputs": {
      "host": {
         "connection": {
            "name": "@parameters('$connections')['office365']['connectionId']"
         }
      },
      "method": "get",
      "path": "/Mail/OnNewEmail",
      "queries": {
          "fetchOnlyWithAttachment": false,
          "folderPath": "Inbox",
          "importance": "Any",
          "includeAttachments": false
      }
   },
   "recurrence": {
      "frequency": "Day",
      "interval": 1
   }
}

ApiConnectionWebhook 触发器ApiConnectionWebhook trigger

此触发器使用 Azure 托管 API 向终结点发送订阅请求,提供供此终结点将响应发送到其中的回叫 URL,然后等待终结点响应。This trigger sends a subscription request to an endpoint by using a Azure-managed API, provides a callback URL to where the endpoint can send a response, and waits for the endpoint to respond. 有关详细信息,请参阅终结点订阅For more information, see Endpoint subscriptions.

"<ApiConnectionWebhook_trigger_name>": {
   "type": "ApiConnectionWebhook",
   "inputs": {
      "body": {
          "NotificationUrl": "@{listCallbackUrl()}"
      },
      "host": {
         "connection": {
            "name": "@parameters('$connections')['<connection-name>']['connectionId']"
         }
      },
      "retryPolicy": { "<retry-behavior>" },
      "queries": "<query-parameters>"
   },
   "runTimeConfiguration": {
      "concurrency": {
         "runs": <max-runs>,
         "maximumWaitingRuns": <max-run-queue>
      }
   },
   "splitOn": "<splitOn-expression>",
   "operationOptions": "<operation-option>"
}

必需Required

ValueValue 类型Type 说明Description
<connection-name><connection-name> StringString 工作流使用的托管 API 连接的名称The name for the connection to the managed API that the workflow uses
<body-content> JSON 对象JSON Object 要作为有效负载发送到托管 API 的任何消息内容Any message content to send as payload to the managed API

可选Optional

ValueValue 类型Type 说明Description
<retry-behavior> JSON 对象JSON Object 自定义状态代码为 408、429 和 5XX 的间歇性故障以及任何连接异常的重试行为。Customizes the retry behavior for intermittent failures, which have the 408, 429, and 5XX status code, and any connectivity exceptions. 有关详细信息,请参阅重试策略For more information, see Retry policies.
<query-parameters> JSON 对象JSON Object 要包括在 API 调用中的任何查询参数Any query parameters to include with the API call

例如,"queries": { "api-version": "2018-01-01" } 对象将 ?api-version=2018-01-01 添加到调用。For example, the "queries": { "api-version": "2018-01-01" } object adds ?api-version=2018-01-01 to the call.

<max-runs> IntegerInteger 默认情况下,工作流实例将同时(并发或并行)运行,直到达到默认限制By default, workflow instances run at the same time (concurrently or in parallel) up to the default limit. 若要通过设置新的 值更改此限制,请参阅更改触发器并发To change this limit by setting a new <count> value, see Change trigger concurrency.
<max-runs-queue> IntegerInteger 当工作流已运行最大数量的实例(可基于 runtimeConfiguration.concurrency.runs 属性进行更改)时,任何新运行的实例都会被放入此队列(最多达到默认限制)。When your workflow is already running the maximum number of instances, which you can change based on the runtimeConfiguration.concurrency.runs property, any new runs are put into this queue up to the default limit. 若要更改此默认限制,请参阅更改等待的运行限制To change the default limit, see Change waiting runs limit.
<splitOn-expression> StringString 对于返回数组的触发器,此表达式引用要使用的数组,从而可为每个数组项创建和运行一个工作流实例,而不是使用“for each”循环。For triggers that return arrays, this expression references the array to use so that you can create and run a workflow instance for each array item, rather than use a "for each" loop.

例如,此表达式表示触发器正文内容中返回的数组中的某一项:@triggerbody()?['value']For example, this expression represents an item in the array returned within the trigger's body content: @triggerbody()?['value']

<operation-option> StringString 通过设置 operationOptions 属性可更改默认行为。You can change the default behavior by setting the operationOptions property. 有关详细信息,请参阅操作选项For more information, see Operation options.

示例Example

此触发器定义订阅 Office 365 Outlook API,提供 API 终结点的回叫 URL,并在新邮件到达时等待终结点响应。This trigger definition subscribes to the Office 365 Outlook API, provides a callback URL to the API endpoint, and waits for the endpoint to respond when a new email arrives.

"When_a_new_email_arrives_(webhook)": {
   "type": "ApiConnectionWebhook",
   "inputs": {
      "body": {
         "NotificationUrl": "@{listCallbackUrl()}" 
      },
      "host": {
         "connection": {
            "name": "@parameters('$connections')['office365']['connectionId']"
         }
      },
      "path": "/MailSubscription/$subscriptions",
      "queries": {
          "folderPath": "Inbox",
          "hasAttachment": "Any",
          "importance": "Any"
      }
   },
   "splitOn": "@triggerBody()?['value']"
}

HTTP 触发器HTTP trigger

此触发器基于指定的定期计划向指定的 HTTP 或 HTTPS 终结点发送请求。This trigger sends a request to the specified HTTP or HTTPS endpoint based on the specified recurrence schedule. 然后,此触发器检查响应以确定工作流是否运行。The trigger then checks the response to determine whether the workflow runs. 有关详细信息,请参阅从 Azure 逻辑应用通过 HTTP 或 HTTPS 调用服务终结点For more information, see Call service endpoints over HTTP or HTTPS from Azure Logic Apps.

"HTTP": {
   "type": "Http",
   "inputs": {
      "method": "<method-type>",
      "uri": "<HTTP-or-HTTPS-endpoint-URL>",
      "headers": { "<header-content>" },
      "queries": "<query-parameters>",
      "body": "<body-content>",
      "authentication": { "<authentication-type-and-property-values>" },
      "retryPolicy": {
         "type": "<retry-behavior>"
      }
   },
   "recurrence": {
      "frequency": "<time-unit>",
      "interval": <number-of-time-units>
   },
   "runtimeConfiguration": {
      "concurrency": {
         "runs": <max-runs>,
         "maximumWaitingRuns": <max-runs-queue>
      }
   },
   "operationOptions": "<operation-option>"
}

必需Required

属性Property ValueValue 类型Type 说明Description
method <method-type> StringString 用于发送传出请求的方法:“GET”、“PUT”、“POST”、“PATCH”或“DELETE”The method to use for sending the outgoing request: "GET", "PUT", "POST", "PATCH", or "DELETE"
uri <HTTP-or-HTTPS-endpoint-URL> StringString 需在其中发送传出请求的 HTTP 或 HTTPS 终结点 URL。The HTTP or HTTPS endpoint URL where you want to send the outgoing request. 最大字符串大小:2 KBMaximum string size: 2 KB

对于 Azure 服务或资源,此 URI 语法包括要访问的资源的资源 ID 和路径。For an Azure service or resource, this URI syntax includes the resource ID and the path to the resource that you want to access.

frequency <time-unit><time-unit> StringString 用于描述触发器触发频率的时间单位:“秒”、“分钟”、“小时”、“天”、“周”、“月”The unit of time that describes how often the trigger fires: "Second", "Minute", "Hour", "Day", "Week", "Month"
interval <number-of-time-units><number-of-time-units> IntegerInteger 指定触发器触发频率的值,即触发器再次触发之前需等待的时间单位数A value that specifies how often the trigger fires based on the frequency, which is the number of time units to wait until the trigger fires again

下面是最小和最大间隔:Here are the minimum and maximum intervals:

- 月:1-16 个月- Month: 1-16 months
- 天:1-500 天- Day: 1-500 days
- 小时:1-12,000 小时- Hour: 1-12,000 hours
- 分钟:1-72,000 分钟- Minute: 1-72,000 minutes
- 秒:1-9,999,999 秒- Second: 1-9,999,999 seconds

例如,如果间隔为 6,频率为“月”,则重复周期为每 6 个月。For example, if the interval is 6, and the frequency is "Month", the recurrence is every 6 months.

可选Optional

属性Property ValueValue 类型Type 说明Description
headers <header-content> JSON 对象JSON Object 需包括在请求中的任何标头Any headers that you need to include with the request

例如,设置语言和类型:For example, to set the language and type:

"headers": { "Accept-Language": "en-us", "Content-Type": "application/json" }

queries <query-parameters> JSON 对象JSON Object 需在请求中使用的任何查询参数Any query parameters that you need to use in the request

例如,"queries": { "api-version": "2018-01-01" } 对象将 ?api-version=2018-01-01 添加到请求。For example, the "queries": { "api-version": "2018-01-01" } object adds ?api-version=2018-01-01 to the request.

body <body-content> JSON 对象JSON Object 要作为有效负载与请求一同发送的消息内容The message content to send as payload with the request
authentication <authentication-type-and-property-values><authentication-type-and-property-values> JSON 对象JSON Object 身份验证模型,请求用它对出站请求进行身份验证。The authentication model that the request uses for authenticating outbound requests. 有关详细信息,请参阅针对出站调用添加身份验证For more information, see Add authentication to outbound calls. 除计划程序外,还支持 authority 属性。Beyond Scheduler, the authority property is supported. 如果未指定此值,则默认值为 https://management.azure.com/,但当你访问 Azure 中国云时,应当使用一个不同的值,即 https://management.chinacloudapi.cn/When not specified, the default value is https://management.azure.com/, but you should use a different value https://management.chinacloudapi.cn/ when you access Azure China Cloud.
retryPolicy > type <retry-behavior> JSON 对象JSON Object 自定义状态代码为 408、429 和 5XX 的间歇性故障以及任何连接异常的重试行为。Customizes the retry behavior for intermittent failures, which have the 408, 429, and 5XX status code, and any connectivity exceptions. 有关详细信息,请参阅重试策略For more information, see Retry policies.
runs <max-runs> IntegerInteger 默认情况下,工作流实例将同时(并发或并行)运行,直到达到默认限制By default, workflow instances run at the same time (concurrently or in parallel) up to the default limit. 若要通过设置新的 值更改此限制,请参阅更改触发器并发To change this limit by setting a new <count> value, see Change trigger concurrency.
maximumWaitingRuns <max-runs-queue> IntegerInteger 当工作流已运行最大数量的实例(可基于 runtimeConfiguration.concurrency.runs 属性进行更改)时,任何新运行的实例都会被放入此队列(最多达到默认限制)。When your workflow is already running the maximum number of instances, which you can change based on the runtimeConfiguration.concurrency.runs property, any new runs are put into this queue up to the default limit. 若要更改此默认限制,请参阅更改等待的运行限制To change the default limit, see Change waiting runs limit.
operationOptions <operation-option> StringString 通过设置 operationOptions 属性可更改默认行为。You can change the default behavior by setting the operationOptions property. 有关详细信息,请参阅操作选项For more information, see Operation options.

输出Outputs

元素Element 类型Type 说明Description
headers JSON 对象JSON Object 响应的标头The headers from the response
body JSON 对象JSON Object 响应的正文The body from the response
status code IntegerInteger 响应中的状态代码The status code from the response

传入请求的要求Requirements for incoming requests

为很好地配合逻辑应用进行工作,终结点必须符合特定触发器模式或协定,并识别以下响应属性:To work well with your logic app, the endpoint must conform to a specific trigger pattern or contract, and recognize these response properties:

属性Property 必须Required 说明Description
状态代码Status code Yes “200 OK”状态代码启动运行。The "200 OK" status code starts a run. 其他任何状态代码均不会启动运行。Any other status code doesn't start a run.
重试间隔标头Retry-after header No 逻辑应用再次轮询终结点之前所要经过的秒数The number of seconds until your logic app polls the endpoint again
Location 标头Location header No 在下一个轮询间隔要调用的 URL。The URL to call at the next polling interval. 如果未指定,将使用原始 URL。If not specified, the original URL is used.

不同请求的示例行为Example behaviors for different requests

状态代码Status code 重试间隔Retry after 行为Behavior
200200 {无}{none} 运行工作流,然后在定义的重复周期后再次检查是否有更多数据。Run the workflow, then check again for more data after the defined recurrence.
200200 10 秒10 seconds 运行工作流,然后在 10 秒后再次检查是否有更多数据。Run the workflow, then check again for more data after 10 seconds.
202202 60 秒60 seconds 不会触发工作流。Don't trigger the workflow. 下一次尝试将在一分钟后发生,也需要遵循定义的重复周期。The next attempt happens in one minute, subject to the defined recurrence. 如果定义的重复周期不到一分钟,重试间隔标头优先。If the defined recurrence is less than one minute, the retry-after header takes precedence. 否则,将使用定义的重复周期。Otherwise, the defined recurrence is used.
400400 {无}{none} 错误的请求,不会运行工作流。Bad request, don't run the workflow. 如果未定义 retryPolicy,将使用默认策略。If no retryPolicy is defined, then the default policy is used. 在达到重试次数后,触发器会在定义的重复周期后再次检查是否有数据。After the number of retries has been reached, the trigger checks again for data after the defined recurrence.
500500 {无}{none} 服务器错误,不会运行工作流。Server error, don't run the workflow. 如果未定义 retryPolicy,将使用默认策略。If no retryPolicy is defined, then the default policy is used. 在达到重试次数后,触发器会在定义的重复周期后再次检查是否有数据。After the number of retries has been reached, the trigger checks again for data after the defined recurrence.

HTTPWebhook 触发器HTTPWebhook trigger

此触发器创建一个可通过调用指定终结点 URL 来注册订阅的终结点,使逻辑应用可被调用。This trigger makes your logic app callable by creating an endpoint that can register a subscription by calling the specified endpoint URL. 在工作流中创建此触发器时,传出请求会进行调用以注册订阅。When you create this trigger in your workflow, an outgoing request makes the call to register the subscription. 这样,该触发器便可开始侦听事件。That way, the trigger can start listening for events. 当某个操作使该触发器无效时,传出请求会自动进行调用以取消订阅。When an operation makes this trigger invalid, an outgoing request automatically makes the call to cancel the subscription. 有关详细信息,请参阅终结点订阅For more information, see Endpoint subscriptions.

此外,还可对 HTTP Webhook 触发器指定异步限制You can also specify asynchronous limits on an HTTPWebhook trigger. 该触发器的行为取决于使用或省略的部分。The trigger's behavior depends on the sections that you use or omit.

"HTTP_Webhook": {
   "type": "HttpWebhook",
   "inputs": {
      "subscribe": {
         "method": "<method-type>",
         "uri": "<endpoint-subscribe-URL>",
         "headers": { "<header-content>" },
         "body": "<body-content>",
         "authentication": { "<authentication-type>" },
         "retryPolicy": { "<retry-behavior>" }
         },
      },
      "unsubscribe": {
         "method": "<method-type>",
         "url": "<endpoint-unsubscribe-URL>",
         "headers": { "<header-content>" },
         "body": "<body-content>",
         "authentication": { "<authentication-type>" }
      }
   },
   "runTimeConfiguration": {
      "concurrency": {
         "runs": <max-runs>,
         "maximumWaitingRuns": <max-runs-queue>
      }
   },
   "operationOptions": "<operation-option>"
}

某些值对 "subscribe""unsubscribe" 对象均可用,例如 Some values, such as <method-type>, are available for both the "subscribe" and "unsubscribe" objects.

必需Required

ValueValue 类型Type 说明Description
<method-type> StringString 用于订阅请求的 HTTP 方法:“GET”、“PUT”、“POST”、“PATCH”或“DELETE”The HTTP method to use for the subscription request: "GET", "PUT", "POST", "PATCH", or "DELETE"
<endpoint-subscribe-URL> StringString 要将订阅请求发送到的终结点 URLThe endpoint URL where to send the subscription request

可选Optional

ValueValue 类型Type 说明Description
<method-type> StringString 用于取消请求的 HTTP 方法:“GET”、“PUT”、“POST”、“PATCH”或“DELETE”The HTTP method to use for the cancellation request: "GET", "PUT", "POST", "PATCH", or "DELETE"
<endpoint-unsubscribe-URL> StringString 要将取消请求发送到的终结点 URLThe endpoint URL where to send the cancellation request
<body-content> StringString 要在订阅请求或取消订阅请求中发送的任何消息内容Any message content to send in the subscription or cancellation request
<authentication-type><authentication-type> JSON 对象JSON Object 身份验证模型,请求用它对出站请求进行身份验证。The authentication model that the request uses for authenticating outbound requests. 有关详细信息,请参阅针对出站调用添加身份验证For more information, see Add authentication to outbound calls.
<retry-behavior> JSON 对象JSON Object 自定义状态代码为 408、429 和 5XX 的间歇性故障以及任何连接异常的重试行为。Customizes the retry behavior for intermittent failures, which have the 408, 429, and 5XX status code, and any connectivity exceptions. 有关详细信息,请参阅重试策略For more information, see Retry policies.
<max-runs> IntegerInteger 默认情况下,所有工作流实例都同时(并发或并行)运行,直到达到默认限制By default, workflow instances all run at the same time (concurrently or in parallel) up to the default limit. 若要通过设置新的 值更改此限制,请参阅更改触发器并发To change this limit by setting a new <count> value, see Change trigger concurrency.
<max-runs-queue> IntegerInteger 当工作流已运行最大数量的实例(可基于 runtimeConfiguration.concurrency.runs 属性进行更改)时,任何新运行的实例都会被放入此队列(最多达到默认限制)。When your workflow is already running the maximum number of instances, which you can change based on the runtimeConfiguration.concurrency.runs property, any new runs are put into this queue up to the default limit. 若要更改此默认限制,请参阅更改等待的运行限制To change the default limit, see Change waiting runs limit.
<operation-option> StringString 通过设置 operationOptions 属性可更改默认行为。You can change the default behavior by setting the operationOptions property. 有关详细信息,请参阅操作选项For more information, see Operation options.

输出Outputs

元素Element 类型Type 说明Description
headersheaders JSON 对象JSON Object 响应的标头The headers from the response
bodybody JSON 对象JSON Object 响应的正文The body from the response
状态代码status code IntegerInteger 响应中的状态代码The status code from the response

示例Example

此触发器创建指定终结点的订阅,提供唯一的回叫 URL,并等待新发布的技术文章。This trigger creates a subscription to the specified endpoint, provides a unique callback URL, and waits for newly published technology articles.

"HTTP_Webhook": {
   "type": "HttpWebhook",
   "inputs": {
      "subscribe": {
         "method": "POST",
         "uri": "https://pubsubhubbub.appspot.com/subscribe",
         "body": {
            "hub.callback": "@{listCallbackUrl()}",
            "hub.mode": "subscribe",
            "hub.topic": "https://pubsubhubbub.appspot.com/articleCategories/technology"
         },
      },
      "unsubscribe": {
         "method": "POST",
         "url": "https://pubsubhubbub.appspot.com/subscribe",
         "body": {
            "hub.callback": "@{workflow().endpoint}@{listCallbackUrl()}",
            "hub.mode": "unsubscribe",
            "hub.topic": "https://pubsubhubbub.appspot.com/articleCategories/technology"
         }
      }
   }
}

重复触发器Recurrence trigger

此触发器的运行基于指定的重复计划,借助它可轻松创建定期运行的工作流。This trigger runs based on the specified recurrence schedule and provides an easy way for creating a regularly running workflow.

"Recurrence": {
   "type": "Recurrence",
   "recurrence": {
      "frequency": "<time-unit>",
      "interval": <number-of-time-units>,
      "startTime": "<start-date-time-with-format-YYYY-MM-DDThh:mm:ss>",
      "timeZone": "<time-zone>",
      "schedule": {
         // Applies only when frequency is Day or Week. Separate values with commas.
         "hours": [ <one-or-more-hour-marks> ], 
         // Applies only when frequency is Day or Week. Separate values with commas.
         "minutes": [ <one-or-more-minute-marks> ], 
         // Applies only when frequency is Week. Separate values with commas.
         "weekDays": [ "Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday" ] 
      }
   },
   "runtimeConfiguration": {
      "concurrency": {
         "runs": <max-runs>,
         "maximumWaitingRuns": <max-runs-queue>
      }
   },
   "operationOptions": "<operation-option>"
}

必需Required

ValueValue 类型Type 说明Description
<time-unit><time-unit> StringString 用于描述触发器触发频率的时间单位:“秒”、“分钟”、“小时”、“天”、“周”、“月”The unit of time that describes how often the trigger fires: "Second", "Minute", "Hour", "Day", "Week", "Month"
<number-of-time-units><number-of-time-units> IntegerInteger 指定触发器触发频率的值,即触发器再次触发之前需等待的时间单位数A value that specifies how often the trigger fires based on the frequency, which is the number of time units to wait until the trigger fires again

下面是最小和最大间隔:Here are the minimum and maximum intervals:

- 月:1-16 个月- Month: 1-16 months
- 天:1-500 天- Day: 1-500 days
- 小时:1-12,000 小时- Hour: 1-12,000 hours
- 分钟:1-72,000 分钟- Minute: 1-72,000 minutes
- 秒:1-9,999,999 秒- Second: 1-9,999,999 seconds

例如,如果间隔为 6,频率为“月”,则重复周期为每 6 个月。For example, if the interval is 6, and the frequency is "Month", the recurrence is every 6 months.

可选Optional

ValueValue 类型Type 说明Description
start-date-time-with-format-YYYY-MM-DDThh:mm:ss<start-date-time-with-format-YYYY-MM-DDThh:mm:ss> StringString 采用以下格式的启动日期和时间:The start date and time in this format:

如果指定时区,则为 YYYY-MM-DDThh:mm:ssYYYY-MM-DDThh:mm:ss if you specify a time zone

-或--or-

如果不指定时区,则为 YYYY-MM-DDThh:mm:ssZYYYY-MM-DDThh:mm:ssZ if you don't specify a time zone

例如,如果需要 2017 年 9 月 18 日下午 2:00,则指定“2017-09-18T14:00:00”并指定时区(如“太平洋标准时间”),或仅指定“2017-09-18T14:00:00Z”,而不指定时区。So for example, if you want September 18, 2017 at 2:00 PM, then specify "2017-09-18T14:00:00" and specify a time zone such as "Pacific Standard Time", or specify "2017-09-18T14:00:00Z" without a time zone.

注意: 此开始时间在未来最长为 49 年,并且必须遵循 UTC 日期时间格式ISO 8601 日期时间规范,但没有 UTC 时差Note: This start time has a maximum of 49 years in the future and must follow the ISO 8601 date time specification in UTC date time format, but without a UTC offset. 如果未指定时区,则必须在末尾添加字母“Z”(无空格)。If you don't specify a time zone, you must add the letter "Z" at the end without any spaces. 这个“Z”指等效的航海时间This "Z" refers to the equivalent nautical time.

对于简单计划,开始时间指首次运行时间;对于复杂计划,触发器的激发时间不会早于开始时间。For simple schedules, the start time is the first occurrence, while for complex schedules, the trigger doesn't fire any sooner than the start time. 有关启动日期和时间的详细信息,请参阅创建和计划定期运行任务For more information about start dates and times, see Create and schedule regularly running tasks.

<time-zone> StringString 仅当指定启动时间时才适用,因为此触发器不接受 UTC 时差Applies only when you specify a start time because this trigger doesn't accept UTC offset. 指定要应用的时区。Specify the time zone that you want to apply.
<one-or-more-hour-marks> 整数或整数数组Integer or integer array 如果为 frequency 指定“Day”或“Week”,可以从 0 到 23 范围内指定一个或多个整数(用逗号分隔),作为一天中要运行工作流的时间点。If you specify "Day" or "Week" for frequency, you can specify one or more integers from 0 to 23, separated by commas, as the hours of the day when you want to run the workflow.

例如,如果指定“10”、“12”和“14”,则会将上午 10 点、中午 12 点和下午 2 点作为小时标记。For example, if you specify "10", "12" and "14", you get 10 AM, 12 PM, and 2 PM as the hour marks.

<one-or-more-minute-marks> 整数或整数数组Integer or integer array 如果为 frequency 指定“Day”或“Week”,可以从 0 到 59 范围内指定一个或多个整数(用逗号分隔),作为要运行工作流的分钟。If you specify "Day" or "Week" for frequency, you can specify one or more integers from 0 to 59, separated by commas, as the minutes of the hour when you want to run the workflow.

例如,可以指定“30”作为分钟标记并使用前面示例中的当天小时时间,这样,便可以指定10:30 AM、12:30 PM 和 2:30 PM 作为开始时间。For example, you can specify "30" as the minute mark and using the previous example for hours of the day, you get 10:30 AM, 12:30 PM, and 2:30 PM.

工作日weekDays 字符串或字符串数组String or string array 如果 frequency 指定为“周”,则可以指定一天或多天(用逗号分隔)作为运行工作流的时间:“星期一”、“星期二”、“星期三”、“星期四”、“星期五”、“星期六”和“星期日”If you specify "Week" for frequency, you can specify one or more days, separated by commas, when you want to run the workflow: "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", and "Sunday"
<max-runs> IntegerInteger 默认情况下,所有工作流实例都同时(并发或并行)运行,直到达到默认限制By default, workflow instances all run at the same time (concurrently or in parallel) up to the default limit. 若要通过设置新的 值更改此限制,请参阅更改触发器并发To change this limit by setting a new <count> value, see Change trigger concurrency.
<max-runs-queue> IntegerInteger 当工作流已运行最大数量的实例(可基于 runtimeConfiguration.concurrency.runs 属性进行更改)时,任何新运行的实例都会被放入此队列(最多达到默认限制)。When your workflow is already running the maximum number of instances, which you can change based on the runtimeConfiguration.concurrency.runs property, any new runs are put into this queue up to the default limit. 若要更改此默认限制,请参阅更改等待的运行限制To change the default limit, see Change waiting runs limit.
<operation-option> StringString 通过设置 operationOptions 属性可更改默认行为。You can change the default behavior by setting the operationOptions property. 有关详细信息,请参阅操作选项For more information, see Operation options.

示例 1Example 1

此基本重复触发器每日都会运行:This basic recurrence trigger runs daily:

"Recurrence": {
   "type": "Recurrence",
   "recurrence": {
      "frequency": "Day",
      "interval": 1
   }
}

示例 2Example 2

可以指定激发触发器的启动日期和时间。You can specify a start date and time for firing the trigger. 此重复触发器在指定日期启动,然后每日触发:This recurrence trigger starts on the specified date and then fires daily:

"Recurrence": {
   "type": "Recurrence",
   "recurrence": {
      "frequency": "Day",
      "interval": 1,
      "startTime": "2017-09-18T00:00:00Z"
   }
}

示例 3Example 3

此重复触发器在 2017 年 9 月 9 日下午 2:00 启动,并在每周一上午 10:30、中午 12:30 和下午 2:30(太平洋标准时间)触发:This recurrence trigger starts on September 9, 2017 at 2:00 PM, and fires weekly every Monday at 10:30 AM, 12:30 PM, and 2:30 PM Pacific Standard Time:

"Recurrence": {
   "type": "Recurrence",
   "recurrence": {
      "frequency": "Week",
      "interval": 1,
      "schedule": {
         "hours": [ 10, 12, 14 ],
         "minutes": [ 30 ],
         "weekDays": [ "Monday" ]
      },
      "startTime": "2017-09-07T14:00:00",
      "timeZone": "Pacific Standard Time"
   }
}

有关此触发器的详细信息和示例,请参阅创建和计划定期运行任务For more information plus examples for this trigger, see Create and schedule regularly running tasks.

请求触发器Request trigger

该触发器通过创建可接受传入请求的终结点,使逻辑应用可被调用。This trigger makes your logic app callable by creating an endpoint that can accept incoming requests. 对于此终结点,提供一个用于描述和验证触发器从传入请求接收的有效负载或输入的 JSON 架构。For this trigger, provide a JSON schema that describes and validates the payload or inputs that the trigger receives from the incoming request. 此架构还使触发器属性更易于从工作流的后续操作中引用。The schema also makes trigger properties easier to reference from later actions in the workflow.

若要调用此触发器,必须使用 listCallbackUrl API,工作流服务 REST API 中对此 API 进行了说明。To call this trigger, you must use the listCallbackUrl API, which is described in the Workflow Service REST API. 若要了解如何将此触发器用作 HTTP 终结点,请参阅使用 HTTP 终结点调用、触发或嵌套工作流To learn how to use this trigger as an HTTP endpoint, see Call, trigger, or nest workflows with HTTP endpoints.

"manual": {
   "type": "Request",
   "kind": "Http",
   "inputs": {
      "method": "<method-type>",
      "relativePath": "<relative-path-for-accepted-parameter>",
      "schema": {
         "type": "object",
         "properties": { 
            "<property-name>": {
               "type": "<property-type>"
            }
         },
         "required": [ "<required-properties>" ]
      }
   },
   "runTimeConfiguration": {
      "concurrency": {
         "runs": <max-runs>,
         "maximumWaitingRuns": <max-run-queue>
      },
   },
   "operationOptions": "<operation-option>"
}

必需Required

ValueValue 类型Type 说明Description
<property-name> StringString JSON 架构中属性的名称,描述有效负载The name of a property in the JSON schema, which describes the payload
<property-type> StringString 属性的类型The property's type

可选Optional

ValueValue 类型Type 说明Description
<method-type> StringString 传入请求必须用以调用逻辑应用的方法:“GET”、“PUT”、“POST”、“PATCH”、“DELETE”The method that incoming requests must use to call your logic app: "GET", "PUT", "POST", "PATCH", "DELETE"
<relative-path-for-accepted-parameter> StringString 终结点的 URL 可接受的参数的相对路径The relative path for the parameter that your endpoint's URL can accept
<required-properties> ArrayArray 需要值的一个或多个属性One or more properties that require values
<max-runs> IntegerInteger 默认情况下,所有工作流实例都同时(并发或并行)运行,直到达到默认限制By default, workflow instances all run at the same time (concurrently or in parallel) up to the default limit. 若要通过设置新的 值更改此限制,请参阅更改触发器并发To change this limit by setting a new <count> value, see Change trigger concurrency.
<max-runs-queue> IntegerInteger 当工作流已运行最大数量的实例(可基于 runtimeConfiguration.concurrency.runs 属性进行更改)时,任何新运行的实例都会被放入此队列(最多达到默认限制)。When your workflow is already running the maximum number of instances, which you can change based on the runtimeConfiguration.concurrency.runs property, any new runs are put into this queue up to the default limit. 若要更改此默认限制,请参阅更改等待的运行限制To change the default limit, see Change waiting runs limit.
<operation-option> StringString 通过设置 operationOptions 属性可更改默认行为。You can change the default behavior by setting the operationOptions property. 有关详细信息,请参阅操作选项For more information, see Operation options.

示例Example

此触发器指定传入请求必须使用 HTTP POST 方法调用触发器,并且包含验证传入请求输入的架构:This trigger specifies that an incoming request must use the HTTP POST method to call the trigger and includes a schema that validates input from the incoming request:

"manual": {
   "type": "Request",
   "kind": "Http",
   "inputs": {
      "method": "POST",
      "schema": {
         "type": "object",
         "properties": {
            "customerName": {
               "type": "String"
            },
            "customerAddress": { 
               "type": "Object",
               "properties": {
                  "streetAddress": {
                     "type": "string"
                  },
                  "city": {
                     "type": "string"
                  }
               }
            }
         }
      }
   }
}

触发条件Trigger conditions

对于任何触发器且仅对于触发器,可包括一个数组,其中包含一个或多个决定工作流是否应该运行的条件表达式。For any trigger, and only triggers, you can include an array that contains one or more expressions for conditions that determine whether the workflow should run. 若要将 conditions 属性添加到工作流中的触发器,请在代码视图编辑器中打开逻辑应用。To add the conditions property to a trigger in your workflow, open your logic app in the code view editor.

例如,可通过引用 conditions 属性中触发器的状态代码,指定触发器仅在站点返回内部服务器错误时触发:For example, you can specify that a trigger fires only when a website returns an internal server error by referencing the trigger's status code in the conditions property:

"Recurrence": {
   "type": "Recurrence",
   "recurrence": {
      "frequency": "Hour",
      "interval": 1
   },
   "conditions": [ {
      "expression": "@equals(triggers().code, 'InternalServerError')"
   } ]
}

默认情况下,触发器仅在获得“200 OK”响应后触发。By default, a trigger fires only after getting a "200 OK" response. 当表达式引用触发器的状态代码时,将替换触发器的默认行为。When an expression references a trigger's status code, the trigger's default behavior is replaced. 因此,若要触发器针对多个状态代码(例如状态代码“200”和“201”)触发,必须包含此表达式作为条件:So, if you want the trigger to fire for more than one status code, such as the "200" and "201" status code, you must include this expression as your condition:

@or(equals(triggers().code, 200),equals(triggers().code, 201))

触发多个运行Trigger multiple runs

触发器可能会返回一个可供逻辑应用处理的数组,但有时候,“for each”循环可能会花过长的时间来处理每个数组项。If your trigger returns an array for your logic app to process, sometimes a "for each" loop might take too long to process each array item. 此时可改用触发器中的 SplitOn 属性,对数组执行解除批处理操作。Instead, you can use the SplitOn property in your trigger to debatch the array. 解除批处理时会拆分数组项,并启动一个针对每个数组项来运行的新工作流实例。Debatching splits up the array items and starts a new workflow instance that runs for each array item. 多种情况下可以使用此方法。例如,需要轮询一个终结点,而该终结点可能在不同的轮询间隔期之间返回多个新项。This approach is useful, for example, when you want to poll an endpoint that might return multiple new items between polling intervals. 若要了解 SplitOn 在单个逻辑应用运行中可以处理的最大数组项数,请参阅限制和配置For the maximum number of array items that SplitOn can process in a single logic app run, see Limits and configuration.

备注

无法对同步响应模式使用 SplitOn。You can't use SplitOn with a synchronous response pattern. 任何使用 SplitOn 并包括一个响应操作的工作流都会异步运行并即时发送 202 ACCEPTED 响应。Any workflow that uses SplitOn and includes a response action runs asynchronously and immediately sends a 202 ACCEPTED response.

启用触发器并发后,会显著降低 SplitOn 限制When trigger concurrency is enabled, the SplitOn limit is significantly reduced. 如果项数超过此限制,会禁用 SplitOn 功能。If the number of items exceeds this limit, the SplitOn capability is disabled.

如果触发器的 Swagger 文件描述的有效负载是一个数组,则会自动向触发器添加 SplitOn 属性。If your trigger's Swagger file describes a payload that is an array, the SplitOn property is automatically added to your trigger. 否则,请将此属性添加到其数组需要解除批处理的响应有效负载中。Otherwise, add this property inside the response payload that has the array you want to debatch.

示例Example

假设某个 API 返回以下响应:Suppose you have an API that returns this response:

{
   "Status": "Succeeded",
   "Rows": [ 
      { 
         "id": 938109380,
         "name": "customer-name-one"
      },
      {
         "id": 938109381,
         "name": "customer-name-two"
      }
   ]
}

逻辑应用只需要 Rows 中的数组的内容,因此,可以按以下示例所示创建触发器:Your logic app only needs the content from the array in Rows, so you can create a trigger like this example:

"HTTP_Debatch": {
   "type": "Http",
    "inputs": {
        "uri": "https://mydomain.com/myAPI",
        "method": "GET"
    },
   "recurrence": {
      "frequency": "Second",
      "interval": 1
    },
    "splitOn": "@triggerBody()?.Rows"
}

备注

如果使用 SplitOn 命令,则无法获取数组外部的属性。If you use the SplitOn command, you can't get the properties that are outside the array. 因此,就此示例来说,不能在从 API 返回的响应中获取 status 属性。So for this example, you can't get the status property in the response returned from the API.

为了避免在不存在 Rows 属性的情况下发生故障,本示例使用了 ? 运算符。To avoid a failure if the Rows property doesn't exist, this example uses the ? operator.

工作流定义现在可以使用 @triggerBody().name 获取 name 值,即第一个运行中的 "customer-name-one" 和第二个运行中的 "customer-name-two"Your workflow definition can now use @triggerBody().name to get the name values, which are "customer-name-one" from the first run and "customer-name-two" from the second run. 因此,触发器的输出如以下示例所示:So, your trigger outputs look like these examples:

{
   "body": {
      "id": 938109380,
      "name": "customer-name-one"
   }
}
{
   "body": {
      "id": 938109381,
      "name": "customer-name-two"
   }
}

操作概述Actions overview

Azure 逻辑应用提供多种操作类型,每个类型均具有定义操作的唯一行为的不同输入。Azure Logic Apps provides various action types - each with different inputs that define an action's unique behavior. 操作具有以下高级元素,但有一些是可选元素:Actions have these high-level elements, though some are optional:

"<action-name>": {
   "type": "<action-type>",
   "inputs": { 
      "<input-name>": { "<input-value>" },
      "retryPolicy": "<retry-behavior>" 
   },
   "runAfter": { "<previous-trigger-or-action-status>" },
   "runtimeConfiguration": { "<runtime-config-options>" },
   "operationOptions": "<operation-option>"
},

必需Required

ValueValue 类型Type 说明Description
<action-name> StringString 操作的名称The name for the action
<action-type> StringString 操作类型,例如“Http”或“ApiConnection”The action type, for example, "Http" or "ApiConnection"
<input-name> StringString 定义操作行为的输入的名称The name for an input that defines the action's behavior
<input-value> 各种Various 输入值,可为字符串、整数、JSON 对象等The input value, which can be a string, integer, JSON object, and so on
<previous-trigger-or-action-status> JSON 对象JSON Object 在此当前操作可以运行之前,必须立即运行的触发器或操作的名称和结果状态The name and resulting status for the trigger or action that must run immediately before this current action can run

可选Optional

ValueValue 类型Type 说明Description
<retry-behavior> JSON 对象JSON Object 自定义状态代码为 408、429 和 5XX 的间歇性故障以及任何连接异常的重试行为。Customizes the retry behavior for intermittent failures, which have the 408, 429, and 5XX status code, and any connectivity exceptions. 有关详细信息,请参阅“重试策略”。For more information, see Retry policies.
<runtime-config-options> JSON 对象JSON Object 对于某些操作,可通过设置 runtimeConfiguration 属性在运行时更改操作的行为。For some actions, you can change the action's behavior at run time by setting runtimeConfiguration properties. 有关详细信息,请参阅运行时配置设置For more information, see Runtime configuration settings.
<operation-option> StringString 对于某些操作,可通过设置 operationOptions 属性更改默认行为。For some actions, you can change the default behavior by setting the operationOptions property. 有关详细信息,请参阅操作选项For more information, see Operation options.

操作类型列表Action types list

以下为一些常用操作类型:Here are some commonly used action types:

内置操作Built-in actions

操作类型Action type 说明Description
ComposeCompose 从输入创建单个输出,可具有多种类型。Creates a single output from inputs, which can have various types.
FunctionFunction 调用 Azure Function。Calls an Azure Function.
HTTPHTTP 调用 HTTP 终结点。Calls an HTTP endpoint.
JoinJoin 基于数组中的所有项创建一个字符串,并使用指定的分隔符字符分隔这些项。Creates a string from all the items in an array and separates those items with a specified delimiter character.
Parse JSONParse JSON 基于 JSON 内容中的属性创建用户友好型令牌。Creates user-friendly tokens from properties in JSON content. 然后可通过将令牌包含在逻辑应用中来引用这些属性。You can then reference those properties by including the tokens in your logic app.
QueryQuery 基于条件或筛选器使用另一个数组中的项创建数组。Creates an array from items in another array based on a condition or filter.
ResponseResponse 创建针对传入调用或请求的响应。Creates a response to an incoming call or request.
SelectSelect 通过基于指定映射转换另一个数组中的项,使用 JSON 对象创建数组。Creates an array with JSON objects by transforming items from another array based on the specified map.
TableTable 根据数组创建 CSV 或 HTML 表。Creates a CSV or HTML table from an array.
TerminateTerminate 停止正在主动运行的工作流。Stops an actively running workflow.
WaitWait 将工作流暂停指定的时间段或暂停到指定日期和时间。Pauses your workflow for a specified duration or until the specified date and time.
WorkflowWorkflow 将一个工作流嵌套在另一个工作流内。Nests a workflow inside another workflow.

托管的 API 操作Managed API actions

操作类型Action type 说明Description
ApiConnectionApiConnection 使用 Azure 托管 API 调用 HTTP 终结点。Calls an HTTP endpoint by using a Azure-managed API.
ApiConnectionWebhookApiConnectionWebhook 工作方式类似于 HTTP Webhook,但使用 Azure 托管 APIWorks like HTTP Webhook but uses a Azure-managed API.

控制工作流操作Control workflow actions

这些操作有助于控制工作流执行且包含其他操作。These actions help you control workflow execution and include other actions. 从某一控制工作流操作外部,可直接引用该控制工作流操作内的操作。From outside a control workflow action, you can directly reference actions inside that control workflow action. 例如,假如你在某一范围内拥有一个 Http 操作,则可从此工作流任意位置引用 @body('Http') 表达式。For example, if you have an Http action inside a scope, you can reference the @body('Http') expression from anywhere in the workflow. 但是,控制工作流操作内部存在的操作仅可在相同控制工作流结构中的其他操作“之后运行”。However, actions that exist inside a control workflow action can only "run after" other actions that are in the same control workflow structure.

操作类型Action type 说明Description
ForEachForEach 在循环中对数组中的每个项执行相同的操作。Run the same actions in a loop for every item in an array.
IfIf 基于指定条件为 true 还是为 false 来运行操作。Run actions based on whether the specified condition is true or false.
ScopeScope 基于组状态从一组操作中运行操作。Run actions based on the group status from a set of actions.
SwitchSwitch 当表达式、对象或令牌的值匹配各事例指定的值时,运行被组织为事例的操作。Run actions organized into cases when values from expressions, objects, or tokens match the values specified by each case.
UntilUntil 在循环中运行操作,直至指定条件为 true。Run actions in a loop until the specified condition is true.

操作 - 详细参考Actions - Detailed reference

APIConnection 操作APIConnection action

此操作将 HTTP 请求发送到 Azure 托管 API,且需要有关该 API 和参数的信息以及对有效连接的引用。This action sends an HTTP request to a Azure-managed API and requires information about the API and parameters plus a reference to a valid connection.

"<action-name>": {
   "type": "ApiConnection",
   "inputs": {
      "host": {
         "connection": {
            "name": "@parameters('$connections')['<api-name>']['connectionId']"
         },
         "<other-action-specific-input-properties>"        
      },
      "method": "<method-type>",
      "path": "/<api-operation>",
      "retryPolicy": "<retry-behavior>",
      "queries": { "<query-parameters>" },
      "<other-action-specific-properties>"
    },
    "runAfter": {}
}

必需Required

ValueValue 类型Type 说明Description
<action-name> StringString 连接器提供的操作的名称The name of the action provided by the connector
<api-name> StringString 用于连接的 Azure 托管 API 的名称The name of the Azure-managed API that is used for the connection
<method-type> StringString 用于调用 API 的 HTTP 方法:“GET”、“PUT”、“POST”、“PATCH”或“DELETE”The HTTP method for calling the API: "GET", "PUT", "POST", "PATCH", or "DELETE"
<api-operation> StringString 要调用的 API 操作The API operation to call

可选Optional

ValueValue 类型Type 说明Description
<other-action-specific-input-properties> JSON 对象JSON Object 应用于此指定操作的任何其他输入属性Any other input properties that apply to this specific action
<retry-behavior> JSON 对象JSON Object 自定义状态代码为 408、429 和 5XX 的间歇性故障以及任何连接异常的重试行为。Customizes the retry behavior for intermittent failures, which have the 408, 429, and 5XX status code, and any connectivity exceptions. 有关详细信息,请参阅重试策略For more information, see Retry policies.
<query-parameters> JSON 对象JSON Object 要包括在 API 调用中的任何查询参数。Any query parameters to include with the API call.

例如,"queries": { "api-version": "2018-01-01" } 对象将 ?api-version=2018-01-01 添加到调用。For example, the "queries": { "api-version": "2018-01-01" } object adds ?api-version=2018-01-01 to the call.

<other-action-specific-properties> JSON 对象JSON Object 应用于此指定操作的任何其他属性Any other properties that apply to this specific action

示例Example

此定义描述了 Office 365 Outlook 连接器(一个 Azure 托管 API)的“发送电子邮件”操作:This definition describes the Send an email action for Office 365 Outlook connector, which is a Azure-managed API:

"Send_an_email": {
   "type": "ApiConnection",
   "inputs": {
      "body": {
         "Body": "Thank you for your membership!",
         "Subject": "Hello and welcome!",
         "To": "Sophie.Owen@contoso.com"
      },
      "host": {
         "connection": {
            "name": "@parameters('$connections')['office365']['connectionId']"
         }
      },
      "method": "POST",
      "path": "/Mail"
    },
    "runAfter": {}
}

APIConnectionWebhook 操作APIConnectionWebhook action

此操作使用 Azure 托管 API 通过 HTTP 向终结点发送订阅请求,提供供此终结点将响应发送到其中的回叫 URL,然后等待终结点响应。This action sends a subscription request over HTTP to an endpoint by using a Azure-managed API, provides a callback URL to where the endpoint can send a response, and waits for the endpoint to respond. 有关详细信息,请参阅终结点订阅For more information, see Endpoint subscriptions.

"<action-name>": {
   "type": "ApiConnectionWebhook",
   "inputs": {
      "subscribe": {
         "method": "<method-type>",
         "uri": "<api-subscribe-URL>",
         "headers": { "<header-content>" },
         "body": "<body-content>",
         "authentication": { "<authentication-type>" },
         "retryPolicy": "<retry-behavior>",
         "queries": { "<query-parameters>" },
         "<other-action-specific-input-properties>"
      },
      "unsubscribe": {
         "method": "<method-type>",
         "uri": "<api-unsubscribe-URL>",
         "headers": { "<header-content>" },
         "body": "<body-content>",
         "authentication": { "<authentication-type>" },
         "<other-action-specific-properties>"
      },
   },
   "runAfter": {}
}

某些值对 "subscribe""unsubscribe" 对象均可用,例如 Some values, such as <method-type>, are available for both the "subscribe" and "unsubscribe" objects.

必需Required

ValueValue 类型Type 说明Description
<action-name> StringString 连接器提供的操作的名称The name of the action provided by the connector
<method-type> StringString 用于从终结点订阅或取消订阅的 HTTP 方法:“GET”、“PUT”、“POST”、“PATCH”或“DELETE”The HTTP method to use for subscribing or unsubscribing from an endpoint: "GET", "PUT", "POST", "PATCH", or "DELETE"
<api-subscribe-URL> StringString 用于订阅 API 的 URIThe URI to use for subscribing to the API

可选Optional

ValueValue 类型Type 说明Description
<api-unsubscribe-URL> StringString 用于取消订阅 API 的 URIThe URI to use for unsubscribing from the API
<header-content> JSON 对象JSON Object 请求中发送的任何标头Any headers to send in the request

例如,在请求中设置语言和类型:For example, to set the language and type on a request:

"headers": { "Accept-Language": "en-us", "Content-Type": "application/json" }

<body-content> JSON 对象JSON Object 请求中发送的任何消息内容Any message content to send in the request
<authentication-type><authentication-type> JSON 对象JSON Object 身份验证模型,请求用它对出站请求进行身份验证。The authentication model that the request uses for authenticating outbound requests. 有关详细信息,请参阅针对出站调用添加身份验证For more information, see Add authentication to outbound calls.
<retry-behavior> JSON 对象JSON Object 自定义状态代码为 408、429 和 5XX 的间歇性故障以及任何连接异常的重试行为。Customizes the retry behavior for intermittent failures, which have the 408, 429, and 5XX status code, and any connectivity exceptions. 有关详细信息,请参阅重试策略For more information, see Retry policies.
<query-parameters> JSON 对象JSON Object 要包括在 API 调用中的任何查询参数Any query parameters to include with the API call

例如,"queries": { "api-version": "2018-01-01" } 对象将 ?api-version=2018-01-01 添加到调用。For example, the "queries": { "api-version": "2018-01-01" } object adds ?api-version=2018-01-01 to the call.

<other-action-specific-input-properties> JSON 对象JSON Object 应用于此指定操作的任何其他输入属性Any other input properties that apply to this specific action
<other-action-specific-properties> JSON 对象JSON Object 应用于此指定操作的任何其他属性Any other properties that apply to this specific action

还可像指定 HTTP 异步限制一样,针对 ApiConnectionWebhook 操作指定限制。You can also specify limits on an ApiConnectionWebhook action in the same way as HTTP asynchronous limits.

Compose 操作Compose action

此操作基于多个输入(包括表达式)创建一个单一输出。This action creates a single output from multiple inputs, including expressions. 输出和输入均可具有 Azure 逻辑应用本机支持的任何类型,例如数组、JSON 对象、XML 和二进制文件。Both the output and inputs can have any type that Azure Logic Apps natively supports, such as arrays, JSON objects, XML, and binary. 此操作的输出之后可用于其他操作。You can then use the action's output in other actions.

"Compose": {
   "type": "Compose",
   "inputs": "<inputs-to-compose>",
   "runAfter": {}
},

必需Required

ValueValue 类型Type 说明Description
<inputs-to-compose> 任意Any 用于创建一个单一输出的输入The inputs for creating a single output

示例 1Example 1

此操作定义合并 abcdefg 与尾随空格和值 1234This action definition merges abcdefg with a trailing space and the value 1234:

"Compose": {
   "type": "Compose",
   "inputs": "abcdefg 1234",
   "runAfter": {}
},

以下为此操作创建的输出:Here is the output that this action creates:

abcdefg 1234

示例 2Example 2

此操作定义合并包含 abcdefg 的字符串变量与包含 1234 的整数变量:This action definition merges a string variable that contains abcdefg and an integer variable that contains 1234:

"Compose": {
   "type": "Compose",
   "inputs": "@{variables('myString')}@{variables('myInteger')}",
   "runAfter": {}
},

以下为此操作创建的输出:Here is the output that this action creates:

"abcdefg1234"

函数操作Function action

此操作调用先前创建的 Azure 函数This action calls a previously created Azure function.

"<Azure-function-name>": {
   "type": "Function",
   "inputs": {
     "function": {
        "id": "<Azure-function-ID>"
      },
      "method": "<method-type>",
      "headers": { "<header-content>" },
      "body": { "<body-content>" },
      "queries": { "<query-parameters>" } 
   },
   "runAfter": {}
}

必需Required

ValueValue 类型Type 说明Description
<Azure-function-ID> StringString 要调用的 Azure 函数的资源 ID。The resource ID for the Azure function you want to call. 下面是此值的格式:Here is the format for this value:

“/subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions/"/subscriptions/<Azure-subscription-ID>/resourceGroups/<Azure-resource-group>/providers/Microsoft.Web/sites/<Azure-function-app-name>/functions/<Azure-function-name>"

<method-type> StringString 用于调用函数的 HTTP 方法:“GET”、“PUT”、“POST”、“PATCH”或“DELETE”The HTTP method to use for calling the function: "GET", "PUT", "POST", "PATCH", or "DELETE"

如果未指定,则默认方法为“POST”。If not specified, the default is the "POST" method.

可选Optional

ValueValue 类型Type 说明Description
<header-content> JSON 对象JSON Object 与调用一同发送的任何标头Any headers to send with the call

例如,在请求中设置语言和类型:For example, to set the language and type on a request:

"headers": { "Accept-Language": "en-us", "Content-Type": "application/json" }

<body-content> JSON 对象JSON Object 请求中发送的任何消息内容Any message content to send in the request
<query-parameters> JSON 对象JSON Object 要包括在 API 调用中的任何查询参数Any query parameters to include with the API call

例如,"queries": { "api-version": "2018-01-01" } 对象将 ?api-version=2018-01-01 添加到调用。For example, the "queries": { "api-version": "2018-01-01" } object adds ?api-version=2018-01-01 to the call.

<other-action-specific-input-properties> JSON 对象JSON Object 应用于此指定操作的任何其他输入属性Any other input properties that apply to this specific action
<other-action-specific-properties> JSON 对象JSON Object 应用于此指定操作的任何其他属性Any other properties that apply to this specific action

保存逻辑应用时,逻辑应用引擎会对所引用的函数执行下述检查:When you save your logic app, the Logic Apps engine performs these checks on the referenced function:

  • 工作流必须具有该函数的访问权限。Your workflow must have access to the function.

  • 工作流只能使用标准 HTTP 触发器或泛型 JSON Webhook 触发器。Your workflow can use only a standard HTTP trigger or generic JSON webhook trigger.

    逻辑应用引擎获取并缓存在运行时使用的触发器 URL。The Logic Apps engine gets and caches the trigger's URL, which is used at runtime. 但是,如果任何操作使缓存的 URL 失效,则此 Function 操作会在运行时失败。However, if any operation invalidates the cached URL, the Function action fails at runtime. 若要解决此问题,请再次保存逻辑应用,以便逻辑应用再次获取和缓存此触发器 URL。To fix this issue, save the logic app again so that the logic app gets and caches the trigger URL again.

  • 函数不能定义任何路由。The function can't have any route defined.

  • 仅允许“函数”和“匿名”授权级别。Only "function" and "anonymous" authorization levels are allowed.

示例Example

此操作定义调用先前创建的“GetProductID”函数:This action definition calls the previously created "GetProductID" function:

"GetProductID": {
   "type": "Function",
   "inputs": {
     "function": {
        "id": "/subscriptions/<XXXXXXXXXXXXXXXXXXXX>/resourceGroups/myLogicAppResourceGroup/providers/Microsoft.Web/sites/InventoryChecker/functions/GetProductID"
      },
      "method": "POST",
      "headers": { 
          "x-ms-date": "@utcnow()"
       },
      "body": { 
          "Product_ID": "@variables('ProductID')"
      }
   },
   "runAfter": {}
}

HTTP 操作HTTP action

此操作向指定的 HTTP 或 HTTPS 终结点发送请求并检查响应,以确定工作流是否在运行。This action sends a request to the specified HTTP or HTTPS endpoint and checks the response to determine whether the workflow runs. 有关详细信息,请参阅从 Azure 逻辑应用通过 HTTP 或 HTTPS 调用服务终结点For more information, see Call service endpoints over HTTP or HTTPS from Azure Logic Apps.

"HTTP": {
   "type": "Http",
   "inputs": {
      "method": "<method-type>",
      "uri": "<HTTP-or-HTTPS-endpoint-URL>",
      "headers": { "<header-content>" },
      "queries": { "<query-parameters>" },
      "body": "<body-content>",
      "authentication": { "<authentication-type-and-property-values>" },
      "retryPolicy": {
         "type": "<retry-behavior>"
      },
   },
   "runAfter": {}
}

必需Required

属性Property ValueValue 类型Type 说明Description
method <method-type> StringString 用于发送传出请求的方法:“GET”、“PUT”、“POST”、“PATCH”或“DELETE”The method to use for sending the outgoing request: "GET", "PUT", "POST", "PATCH", or "DELETE"
uri <HTTP-or-HTTPS-endpoint-URL> StringString 需在其中发送传出请求的 HTTP 或 HTTPS 终结点 URL。The HTTP or HTTPS endpoint URL where you want to send the outgoing request. 最大字符串大小:2 KBMaximum string size: 2 KB

对于 Azure 服务或资源,此 URI 语法包括要访问的资源的资源 ID 和路径。For an Azure service or resource, this URI syntax includes the resource ID and the path to the resource that you want to access.

可选Optional

属性Property ValueValue 类型Type 说明Description
headers <header-content> JSON 对象JSON Object 需包括在请求中的任何标头Any headers that you need to include with the request

例如,设置语言和类型:For example, to set the language and type:

"headers": { "Accept-Language": "en-us", "Content-Type": "application/json" }

queries <query-parameters> JSON 对象JSON Object 需在请求中使用的任何查询参数Any query parameters that you need to use in the request

例如,"queries": { "api-version": "2018-01-01" } 对象将 ?api-version=2018-01-01 添加到调用。For example, the "queries": { "api-version": "2018-01-01" } object adds ?api-version=2018-01-01 to the call.

body <body-content> JSON 对象JSON Object 要作为有效负载与请求一同发送的消息内容The message content to send as payload with the request
authentication <authentication-type-and-property-values><authentication-type-and-property-values> JSON 对象JSON Object 身份验证模型,请求用它对出站请求进行身份验证。The authentication model that the request uses for authenticating outbound requests. 有关详细信息,请参阅针对出站调用添加身份验证For more information, see Add authentication to outbound calls. 除计划程序外,还支持 authority 属性。Beyond Scheduler, the authority property is supported. 如果未指定此值,则默认值为 https://management.azure.com/,但当你访问 Azure 中国云时,应当使用一个不同的值,即 https://management.chinacloudapi.cn/When not specified, the default value is https://management.azure.com/, but you should use a different value https://management.chinacloudapi.cn/ when you access Azrue China Cloud.
retryPolicy > type <retry-behavior> JSON 对象JSON Object 自定义状态代码为 408、429 和 5XX 的间歇性故障以及任何连接异常的重试行为。Customizes the retry behavior for intermittent failures, which have the 408, 429, and 5XX status code, and any connectivity exceptions. 有关详细信息,请参阅重试策略For more information, see Retry policies.
<other-action-specific-input-properties> <input-property><input-property> JSON 对象JSON Object 应用于此指定操作的任何其他输入属性Any other input properties that apply to this specific action
<other-action-specific-properties> <property-value><property-value> JSON 对象JSON Object 应用于此指定操作的任何其他属性Any other properties that apply to this specific action

示例Example

此操作定义通过向指定终结点发送请求来获取最新资讯:This action definition gets the latest news by sending a request to the specified endpoint:

"HTTP": {
   "type": "Http",
   "inputs": {
      "method": "GET",
      "uri": "https://mynews.example.com/latest"
   }
}

Join 操作Join action

此操作基于数组中的所有项创建一个字符串,并使用指定的分隔符字符分隔这些项。This action creates a string from all the items in an array and separates those items with the specified delimiter character.

"Join": {
   "type": "Join",
   "inputs": {
      "from": <array>,
      "joinWith": "<delimiter>"
   },
   "runAfter": {}
}

必需Required

ValueValue 类型Type 说明Description
<array> ArrayArray 提供源项的数组或表达式。The array or expression that provides the source items. 如果指定表达式,请将表达式括于双引号内。If you specify an expression, enclose that expression with double quotes.
<delimiter><delimiter> 单字符字符串Single character string 分隔字符串中每个项的字符The character that separates each item in the string

示例Example

假设先前已创建了一个包含此整数数组的“myIntegerArray”变量:Suppose you have a previously created "myIntegerArray" variable that contains this integer array:

[1,2,3,4]

此操作定义通过在表达式中使用 variables() 函数来获取变量中的值,并使用这些值(以逗号隔开)创建此字符串:"1,2,3,4"This action definition gets the values from the variable by using the variables() function in an expression and creates this string with those values, which are separated by a comma: "1,2,3,4"

"Join": {
   "type": "Join",
   "inputs": {
      "from": "@variables('myIntegerArray')",
      "joinWith": ","
   },
   "runAfter": {}
}

Parse JSON 操作Parse JSON action

此操作从 JSON 内容中的属性创建用户友好的字段或令牌。This action creates user-friendly fields or tokens from the properties in JSON content. 之后可改用令牌在逻辑应用中访问这些属性。You can then access those properties in your logic app by using the tokens instead. 例如,要使用 Azure 服务总线和 Azure Cosmos DB 等服务的 JSON 输出时,可将此操作包含在逻辑应用中,以便可更轻松地引用该输出中的数据。For example, when you want to use JSON output from services such as Azure Service Bus and Azure Cosmos DB, you can include this action in your logic app so that you can more easily reference the data in that output.

"Parse_JSON": {
   "type": "ParseJson",
   "inputs": {
      "content": "<JSON-source>",
         "schema": { "<JSON-schema>" }
      },
      "runAfter": {}
},

必需Required

ValueValue 类型Type 说明Description
<JSON-source> JSON 对象JSON Object 要分析的 JSON 内容The JSON content you want to parse
<JSON-schema> JSON 对象JSON Object 描述基础 JSON 内容的 JSON 架构,操作将该架构用于分析源 JSON 内容。The JSON schema that describes the underlying the JSON content, which the action uses for parsing the source JSON content.

提示:在逻辑应用设计器中,可提供该架构或提供示例有效负载,以便操作可生成该架构。Tip: In Logic Apps Designer, you can either provide the schema or provide a sample payload so that the action can generate the schema.

示例Example

此操作定义创建的令牌可在工作流中使用,但仅可在“分析 JSON”操作之后运行的操作中使用:This action definition creates these tokens that you can use in your workflow but only in actions that run following the Parse JSON action:

FirstNameLastNameEmailFirstName, LastName, and Email

"Parse_JSON": {
   "type": "ParseJson",
   "inputs": {
      "content": {
         "Member": {
            "Email": "Sophie.Owen@contoso.com",
            "FirstName": "Sophie",
            "LastName": "Owen"
         }
      },
      "schema": {
         "type": "object",
         "properties": {
            "Member": {
               "type": "object",
               "properties": {
                  "Email": {
                     "type": "string"
                  },
                  "FirstName": {
                     "type": "string"
                  },
                  "LastName": {
                     "type": "string"
                  }
               }
            }
         }
      }
   },
   "runAfter": { }
},

在此示例中,“content”属性指定操作要分析的 JSON 内容。In this example, the "content" property specifies the JSON content for the action to parse. 此外,还可提供此 JSON 内容作为生成该架构的相同有效负载。You can also provide this JSON content as the sample payload for generating the schema.

"content": {
   "Member": { 
      "FirstName": "Sophie",
      "LastName": "Owen",
      "Email": "Sophie.Owen@contoso.com"
   }
},

“schema”属性指定用于描述 JSON 内容的 JSON 架构:The "schema" property specifies the JSON schema used for describing the JSON content:

"schema": {
   "type": "object",
   "properties": {
      "Member": {
         "type": "object",
         "properties": {
            "FirstName": {
               "type": "string"
            },
            "LastName": {
               "type": "string"
            },
            "Email": {
               "type": "string"
            }
         }
      }
   }
}

Query 操作Query action

此操作基于指定条件或筛选器使用另一个数组中的项创建数组。This action creates an array from items in another array based on a specified condition or filter.

"Filter_array": {
   "type": "Query",
   "inputs": {
      "from": <array>,
      "where": "<condition-or-filter>"
   },
   "runAfter": {}
}

必需Required

ValueValue 类型Type 说明Description
<array> ArrayArray 提供源项的数组或表达式。The array or expression that provides the source items. 如果指定表达式,请将表达式括于双引号内。If you specify an expression, enclose that expression with double quotes.
<condition-or-filter> StringString 用于筛选源数组中的项的条件The condition used for filtering items in the source array

注意:如果没有任何值满足此条件,则该操作会创建一个空数组。Note: If no values satisfy the condition, then the action creates an empty array.

示例Example

此操作定义创建一个值大于指定值 2 的数组:This action definition creates an array that has values greater than the specified value, which is two:

"Filter_array": {
   "type": "Query",
   "inputs": {
      "from": [ 1, 3, 0, 5, 4, 2 ],
      "where": "@greater(item(), 2)"
   }
}

Response 操作Response action

此操作创建 HTTP 请求响应的有效负载。This action creates the payload for the response to an HTTP request.

"Response" {
    "type": "Response",
    "kind": "http",
    "inputs": {
        "statusCode": 200,
        "headers": { <response-headers> },
        "body": { <response-body> }
    },
    "runAfter": {}
},

必需Required

ValueValue 类型Type 说明Description
<response-status-code> IntegerInteger 发送到传入请求的 HTTP 状态代码。The HTTP status code that is sent to the incoming request. 默认代码为“200 OK”,但此代码可为以 2xx、4xx 或 5xx(非 3xxx)开头的任何有效状态代码。The default code is "200 OK", but the code can be any valid status code that starts with 2xx, 4xx, or 5xx, but not with 3xxx.

可选Optional

ValueValue 类型Type 说明Description
<response-headers> JSON 对象JSON Object 要包括在响应中的一个或多个标头One or more headers to include with the response
<response-body> 各种Various 响应正文,可为字符串、JSON 对象甚至上一个操作的二进制内容The response body, which can be a string, JSON object, or even binary content from a previous action

示例Example

此操作定义创建一个包含指定状态代码、消息正文和消息标头的 HTTP 请求响应:This action definition creates a response to an HTTP request with the specified status code, message body, and message headers:

"Response": {
   "type": "Response",
   "inputs": {
      "statusCode": 200,
      "body": {
         "ProductID": 0,
         "Description": "Organic Apples"
      },
      "headers": {
         "x-ms-date": "@utcnow()",
         "content-type": "application/json"
      }
   },
   "runAfter": {}
}

限制Restrictions

不同于其他操作,Response 操作具有一些特殊限制:Unlike other actions, the Response action has special restrictions:

  • 工作流仅可在以 HTTP 请求触发器开始时才能使用 Response 操作,即工作流必须由 HTTP 请求触发。Your workflow can use the Response action only when the workflow starts with an HTTP request trigger, meaning your workflow must be triggered by an HTTP request.

  • 工作流可在任意位置使用 Response 操作,但 Foreach 循环和 Until 循环(包括序列循环和并行分支)内除外 。Your workflow can use the Response action anywhere except inside Foreach loops, Until loops, including sequential loops, and parallel branches.

  • 仅当 Response 操作所需的所有操作都在 HTTP 请求超时限制内完成时,原始 HTTP 请求才会获取工作流的响应。The original HTTP request gets your workflow's response only when all actions required by the Response action are finished within the HTTP request timeout limit.

    但是,如果工作流调用另一个逻辑应用作为嵌套工作流,则父级工作流在嵌套工作流完成之前将处于等待状态,而不管嵌套工作流完成需要多久时间。However, if your workflow calls another logic app as a nested workflow, the parent workflow waits until the nested workflow finishes, no matter how much time passes before the nested workflow finishes.

  • 工作流在使用 Response 操作和异步响应模式时,无法还在触发器定义中使用 splitOn 命令,因为该命令会创建多个运行 。When your workflow uses the Response action and a synchronous response pattern, the workflow can't also use the splitOn command in the trigger definition because that command creates multiple runs. 使用 PUT 方法时请检查是否存在这种情况,如果为 true,则会返回“错误的请求”响应。Check for this case when the PUT method is used, and if true, return a "bad request" response.

    否则,如果工作流使用 splitOn 命令和 Response 操作,则工作流会异步运行并立即返回响应“202 ACCEPTED” 。Otherwise, if your workflow uses the splitOn command and a Response action, the workflow runs asynchronously and immediately returns a "202 ACCEPTED" response.

  • 当工作流的执行到达 Response 操作但传入请求已接收响应时,Response 操作会由于冲突而被标记为“Failed” 。When your workflow's execution reaches the Response action, but the incoming request has already received a response, the Response action is marked as "Failed" due to the conflict. 因此,逻辑应用运行也会被标记为“Failed”状态。And as a result, your logic app run is also marked with "Failed" status.

选择操作Select action

此操作通过基于指定映射转换另一个数组中的项,创建包含 JSON 对象的数组。This action creates an array with JSON objects by transforming items from another array based on the specified map. 输出数组和源数组的项数始终相同。The output array and source array always have the same number of items. 虽然无法更改输出数组中的对象数,但可以添加或删除这些对象的属性以及属性值。Although you can't change the number of objects in the output array, you can add or remove properties and their values across those objects. select 属性至少指定一个键值对,此键值对定义用于转换源数组中的项的映射。The select property specifies at least one key-value pair that define the map for transforming items in the source array. 键值对表示输出数组中所有对象的某个属性和该属性的值。A key-value pair represents a property and its value across all the objects in the output array.

"Select": {
   "type": "Select",
   "inputs": {
      "from": <array>,
      "select": { 
          "<key-name>": "<expression>",
          "<key-name>": "<expression>"        
      }
   },
   "runAfter": {}
},

必需Required

ValueValue 类型Type 说明Description
<array> ArrayArray 提供源项的数组或表达式。The array or expression that provides the source items. 确保将表达式放入双引号内。Make sure you enclose an expression with double quotes.

注意:如果源数组为空,则该操作会创建一个空数组。Note: If the source array is empty, the action creates an empty array.

<key-name><key-name> StringString 分配给结果的属性名称The property name assigned to the result from <expression>

若要为输出数组中的所有对象添加一个新属性,请提供该属性的 以及属性值的 To add a new property across all objects in the output array, provide a <key-name> for that property and an <expression> for the property value.

若要从数组的所有对象中删除属性,请删除该属性的 To remove a property from all objects in the array, omit the <key-name> for that property.

<expression><expression> StringString 转换源数组中的项并将结果分配给 的表达式The expression that transforms the item in the source array and assigns the result to <key-name>

Select 操作创建一个数组作为输出,因此,任何想要使用此输出的操作必须接受数组或者该数组必须转换为使用者操作接受的类型。The Select action creates an array as output, so any action that wants to use this output must either accept an array, or you must convert the array into the type that the consumer action accepts. 例如,若要将此输出数组转换为字符串,可将此数组传递到 Compose 操作,然后在其他操作中引用 Compose 操作的输出 。For example, to convert the output array to a string, you can pass that array to the Compose action, and then reference the output from the Compose action in your other actions.

示例Example

此操作定义基于一个整数数组创建 JSON 对象数组。This action definition creates a JSON object array from an integer array. 此操作循环访问此源数组,使用 @item() 表达式获取每个整数值,然后将每个值分配给每个 JSON 对象中的“number”属性:The action iterates through the source array, gets each integer value by using the @item() expression, and assigns each value to the "number" property in each JSON object:

"Select": {
   "type": "Select",
   "inputs": {
      "from": [ 1, 2, 3 ],
      "select": { 
         "number": "@item()" 
      }
   },
   "runAfter": {}
},

以下为此操作创建的数组:Here is the array that this action creates:

[ { "number": 1 }, { "number": 2 }, { "number": 3 } ]

若要在其他操作中使用此数组输出,请将此输出传递到 Compose 操作中:To use this array output in other actions, pass this output into a Compose action:

"Compose": {
   "type": "Compose",
   "inputs": "@body('Select')",
   "runAfter": {
      "Select": [ "Succeeded" ]
   }
},

然后可将 Compose 操作的输出用于其他操作中,例如“Office 365 Outlook - 发送电子邮件”操作 :You can then use the output from the Compose action in your other actions, for example, the Office 365 Outlook - Send an email action:

"Send_an_email": {
   "type": "ApiConnection",
   "inputs": {
      "body": {
         "Body": "@{outputs('Compose')}",
         "Subject": "Output array from Select and Compose actions",
         "To": "<your-email@domain>"
      },
      "host": {
         "connection": {
            "name": "@parameters('$connections')['office365']['connectionId']"
         }
      },
      "method": "post",
      "path": "/Mail"
   },
   "runAfter": {
      "Compose": [ "Succeeded" ]
   }
},

表操作Table action

此操作根据数组创建 CSV 或 HTML 表。This action creates a CSV or HTML table from an array. 对于包含 JSON 对象的数组,此操作根据对象的属性名称自动创建列标头。For arrays with JSON objects, this action automatically creates the column headers from the objects' property names. 对于包含其他数据类型的数组,必须指定列标头和值。For arrays with other data types, you must specify the column headers and values. 例如,此数组包含该操作可用于列标头名称的“ID”和“Product_Name”属性:For example, this array includes the "ID" and "Product_Name" properties that this action can use for the column header names:

[ {"ID": 0, "Product_Name": "Apples"}, {"ID": 1, "Product_Name": "Oranges"} ]

"Create_<CSV | HTML>_table": {
   "type": "Table",
   "inputs": {
      "format": "<CSV | HTML>",
      "from": <array>,
      "columns": [ 
         {
            "header": "<column-name>",
            "value": "<column-value>"
         },
         {
            "header": "<column-name>",
            "value": "<column-value>"
         } 
      ]
   },
   "runAfter": {}
}

必需Required

ValueValue 类型Type 说明Description
<CSV or HTML> StringString 要创建的表的格式The format for the table you want to create
<array> ArrayArray 为表提供源项的数组或表达式The array or expression that provides the source items for the table

注意:如果源数组为空,则该操作会创建一个空表。Note: If the source array is empty, the action creates an empty table.

可选Optional

若要指定或自定义列标头和值,请使用 columns 数组。To specify or customize column headers and values, use the columns array. header-value 对具有相同标头名称时,其值显示在该标头名称下相同的列中。When header-value pairs have the same header name, their values appear in the same column under that header name. 否则,每个唯一的标头定义一个唯一列。Otherwise, each unique header defines a unique column.

ValueValue 类型Type 说明Description
<column-name> StringString 列的标头名称The header name for a column
<column-value> 任意Any 该列中的值The value in that column

示例 1Example 1

假设先前已创建了一个当前包含此数组的“myItemArray”变量:Suppose you have a previously created "myItemArray" variable that currently contains this array:

[ {"ID": 0, "Product_Name": "Apples"}, {"ID": 1, "Product_Name": "Oranges"} ]

此操作定义根据“myItemArray”变量创建一个 CSV 表。This action definition creates a CSV table from the "myItemArray" variable. from 属性使用的表达式通过使用 variables() 函数从“myItemArray”获取数组:The expression used by the from property gets the array from "myItemArray" by using the variables() function:

"Create_CSV_table": {
   "type": "Table",
   "inputs": {
      "format": "CSV",
      "from": "@variables('myItemArray')"
   },
   "runAfter": {}
}

以下为此操作创建的 CSV 表:Here is the CSV table that this action creates:

ID,Product_Name 
0,Apples 
1,Oranges 

示例 2Example 2

此操作定义根据“myItemArray”变量创建一个 HTML 表。This action definition creates an HTML table from the "myItemArray" variable. from 属性使用的表达式通过使用 variables() 函数从“myItemArray”获取数组:The expression used by the from property gets the array from "myItemArray" by using the variables() function:

"Create_HTML_table": {
   "type": "Table",
   "inputs": {
      "format": "HTML",
      "from": "@variables('myItemArray')"
   },
   "runAfter": {}
}

以下为此操作创建的 HTML 表:Here is the HTML table that this action creates:

IDIDProduct_NameProduct_Name
00苹果Apples
11OrangesOranges

示例 3Example 3

此操作定义根据“myItemArray”变量创建一个 HTML 表。This action definition creates an HTML table from the "myItemArray" variable. 但是,本示例使用“Stock_ID”和“Description”替代默认列标头名称,并在“Description”列的值中添加了“Organic”一词。However, this example overrides the default column header names with "Stock_ID" and "Description", and adds the word "Organic" to the values in the "Description" column.

"Create_HTML_table": {
   "type": "Table",
   "inputs": {
      "format": "HTML",
      "from": "@variables('myItemArray')",
      "columns": [ 
         {
            "header": "Stock_ID",
            "value": "@item().ID"
         },
         {
            "header": "Description",
            "value": "@concat('Organic ', item().Product_Name)"
         }
      ]
    },
   "runAfter": {}
},

以下为此操作创建的 HTML 表:Here is the HTML table that this action creates:

Stock_IDStock_ID说明Description
00Organic ApplesOrganic Apples
11Organic OrangesOrganic Oranges

Terminate 操作Terminate action

此操作停止运行工作流实例、取消正在进行的所有操作、跳过任何剩余的操作并返回指定的状态。This action stops the run for a workflow instance, cancels any actions in progress, skips any remaining actions, and returns the specified status. 例如,当逻辑应用由于错误状态而必须完全退出时,可使用此 Terminate 操作。For example, you can use the Terminate action when your logic app must exit completely from an error state. 此操作不影响已经完成的操作,且不能出现在 Foreach 和 Until 循环(包括序列循环)内 。This action doesn't affect already completed actions and can't appear inside Foreach and Until loops, including sequential loops.

"Terminate": {
   "type": "Terminate",
   "inputs": {
       "runStatus": "<status>",
       "runError": {
            "code": "<error-code-or-name>",
            "message": "<error-message>"
       }
   },
   "runAfter": {}
}

必需Required

ValueValue 类型Type 说明Description
<status> StringString 运行返回的状态:“失败”、“已取消”或者“已成功”The status to return for the run: "Failed", "Cancelled", or "Succeeded"

可选Optional

仅在“runStatus”属性设为“Failed”状态时,“runStatus”对象的属性才适用。The properties for the "runStatus" object apply only when the "runStatus" property is set to "Failed" status.

ValueValue 类型Type 说明Description
<error-code-or-name> StringString 错误的代码或名称The code or name for the error
<error-message> StringString 消息或文本,描述错误和应用用户可采取的任何操作The message or text that describes the error and any actions the app user can take

示例Example

此操作定义停止工作流运行,将运行状态设为“Failed”,并返回状态、错误代码和错误消息:This action definition stops a workflow run, sets the run status to "Failed", and returns the status, an error code, and an error message:

"Terminate": {
    "type": "Terminate",
    "inputs": {
        "runStatus": "Failed",
        "runError": {
            "code": "Unexpected response",
            "message": "The service received an unexpected response. Please try again."
        }
   },
   "runAfter": {}
}

Wait 操作Wait action

此操作将工作流执行暂停指定时间间隔或暂停到指定时间(仅二者之一)。This action pauses workflow execution for the specified interval or until the specified time, but not both.

指定时间间隔Specified interval

"Delay": {
   "type": "Wait",
   "inputs": {
      "interval": {
         "count": <number-of-units>,
         "unit": "<interval>"
      }
   },
   "runAfter": {}
},

指定时间Specified time

"Delay_until": {
   "type": "Wait",
   "inputs": {
      "until": {
         "timestamp": "<date-time-stamp>"
      }
   },
   "runAfter": {}
},

必需Required

ValueValue 类型Type 说明Description
<number-of-units> IntegerInteger 对于 Delay 操作,要等待的单位数For the Delay action, the number of units to wait
<间隔><interval> StringString 对于“延迟”操作,等待间隔时间为:“秒”、“分钟”、“小时”、“天”、“周”、“月”For the Delay action, the interval to wait: "Second", "Minute", "Hour", "Day", "Week", "Month"
<date-time-stamp> StringString 对于 Delay Until 操作,执行的恢复日期和时间。For the Delay Until action, the date and time to resume execution. 该值必须使用 UTC 日期时间格式This value must use the UTC date time format.

示例 1Example 1

此操作定义将工作流暂停 15 分钟:This action definition pauses the workflow for 15 minutes:

"Delay": {
   "type": "Wait",
   "inputs": {
      "interval": {
         "count": 15,
         "unit": "Minute"
      }
   },
   "runAfter": {}
},

示例 2Example 2

此操作定义将工作流暂停到指定时间:This action definition pauses the workflow until the specified time:

"Delay_until": {
   "type": "Wait",
   "inputs": {
      "until": {
         "timestamp": "2017-10-01T00:00:00Z"
      }
   },
   "runAfter": {}
},

Workflow 操作Workflow action

此操作调用先前创建的另一个逻辑应用,这意味着可以包含和重复使用其他逻辑应用工作流。This action calls another previously created logic app, which means you can include and reuse other logic app workflows. 如果子级逻辑应用返回响应,则还可将子级或嵌套逻辑应用的输出用于嵌套逻辑应用之后的操作中。You can also use the outputs from the child or nested logic app in actions that follow the nested logic app, provided that the child logic app returns a response.

逻辑应用引擎检查对要调用的触发器的访问权限,确保你有权访问该触发器。The Logic Apps engine checks access to the trigger you want to call, so make sure you can access that trigger. 此外,嵌套逻辑应用还必须满足以下条件:Also, the nested logic app must meet these criteria:

  • 触发器(例如 RequestHTTP 触发器)使嵌套应用可调用A trigger makes the nested logic app callable, such as a Request or HTTP trigger

  • 与父级逻辑应用相同的 Azure 订阅The same Azure subscription as your parent logic app

  • 若要将嵌套逻辑应用的输出用于父级逻辑应用中,嵌套逻辑应用必须具有 Response 操作To use the outputs from the nested logic app in your parent logic app, the nested logic app must have a Response action

"<nested-logic-app-name>": {
   "type": "Workflow",
   "inputs": {
      "body": { "<body-content" },
      "headers": { "<header-content>" },
      "host": {
         "triggerName": "<trigger-name>",
         "workflow": {
            "id": "/subscriptions/<Azure-subscription-ID>/resourceGroups/<Azure-resource-group>/providers/Microsoft.Logic/<nested-logic-app-name>"
         }
      }
   },
   "runAfter": {}
}

必需Required

ValueValue 类型Type 说明Description
<nested-logic-app-name> StringString 要调用的逻辑应用的名称The name for the logic app you want to call
<trigger-name><trigger-name> StringString 要调用的嵌套逻辑应用中的触发器的名称The name for the trigger in the nested logic app you want to call
<Azure-subscription-ID> StringString 嵌套逻辑应用的 Azure 订阅 IDThe Azure subscription ID for the nested logic app
<Azure-resource-group> StringString 嵌套逻辑应用的 Azure 资源组名称The Azure resource group name for the nested logic app
<nested-logic-app-name> StringString 要调用的逻辑应用的名称The name for the logic app you want to call

可选Optional

ValueValue 类型Type 说明Description
<header-content> JSON 对象JSON Object 与调用一同发送的任何标头Any headers to send with the call
<body-content> JSON 对象JSON Object 与调用一同发送的任何消息内容Any message content to send with the call

输出Outputs

此操作的输出基于嵌套应用的 Response 操作而有所不同。This action's outputs vary based on the nested logic app's Response action. 如果嵌套逻辑应用不包含 Response 操作,则输出为空。If the nested logic app doesn't include a Response action, the outputs are empty.

示例Example

“Start_search”操作成功完成后,此工作流操作定义调用名为“Get_product_information”的另一个逻辑应用(该逻辑应用在指定输入中传递):After the "Start_search" action finishes successfully, this workflow action definition calls another logic app named "Get_product_information", which passes in the specified inputs:

"actions": {
   "Start_search": { <action-definition> },
   "Get_product_information": {
      "type": "Workflow",
      "inputs": {
         "body": {
            "ProductID": "24601",
         },
         "host": {
            "id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/InventoryManager-RG/providers/Microsoft.Logic/Get_product_information",
            "triggerName": "Find_product"
         },
         "headers": {
            "content-type": "application/json"
         }
      },
      "runAfter": { 
         "Start_search": [ "Succeeded" ]
      }
   }
},

控制工作流操作详细信息Control workflow action details

Foreach 操作Foreach action

此循环操作循环访问数组并针对每个数组项执行操作。This looping action iterates through an array and performs actions on each array item. 默认情况下,“for each”循环可以多达最大循环数并行运行。By default, the "for each" loop runs in parallel up to a maximum number of loops. 有关此最大值,请参阅限制和配置。了解如何创建“for each”循环For this maximum, see Limits and config. Learn how to create "for each" loops.

"For_each": {
   "type": "Foreach",
   "actions": { 
      "<action-1>": { "<action-definition-1>" },
      "<action-2>": { "<action-definition-2>" }
   },
   "foreach": "<for-each-expression>",
   "runAfter": {},
   "runtimeConfiguration": {
      "concurrency": {
         "repetitions": <count>
      }
    },
    "operationOptions": "<operation-option>"
}

必需Required

ValueValue 类型Type 说明Description
<action-1...n><action-1...n> StringString 在每个数组项上运行的操作的名称The names of the actions that run on each array item
<action-definition-1...n><action-definition-1...n> JSON 对象JSON Object 运行的操作的定义The definitions of the actions that run
<for-each-expression> StringString 用于引用指定数组中每个项的表达式The expression that references each item in the specified array

可选Optional

ValueValue 类型Type 说明Description
<count><count> IntegerInteger 默认情况下,“for each”循环迭代将同时(并发或并行)运行,直到达到默认限制By default, the "for each" loop iterations run at the same time (concurrently or in parallel) up to the default limit. 若要通过设置新的 值更改此限制,请参阅更改“for each”循环并发To change this limit by setting a new <count> value, see Change "for each" loop concurrency.
<operation-option> StringString 若要按顺序而不是并行运行“for each”循环,请将 设为 Sequential 或将 设为 1(仅二者之一) 。To run a "for each" loop sequentially, rather than in parallel, set either <operation-option> to Sequential or <count> to 1, but not both. 有关详细信息,请参阅按顺序运行“for each”循环For more information, see Run "for each" loops sequentially.

示例Example

此“for each”循环为数组中的每个项发送一封电子邮件,其中包含来自传入电子邮件的附件。This "for each" loop sends an email for each item in the array, which contains attachments from an incoming email. 该循环将一封电子邮件(含附件)发送给审阅此附件的人员。The loop sends an email, including the attachment, to a person who reviews the attachment.

"For_each": {
   "type": "Foreach",
   "actions": {
      "Send_an_email": {
         "type": "ApiConnection",
         "inputs": {
            "body": {
               "Body": "@base64ToString(items('For_each')?['Content'])",
               "Subject": "Review attachment",
               "To": "Sophie.Owen@contoso.com"
                },
            "host": {
               "connection": {
                  "id": "@parameters('$connections')['office365']['connectionId']"
               }
            },
            "method": "post",
            "path": "/Mail"
         },
         "runAfter": {}
      }
   },
   "foreach": "@triggerBody()?['Attachments']",
   "runAfter": {}
}

为了仅指定一个作为触发器输出传递的数组,此表达式从触发器正文获取 数组。To specify only an array that is passed as output from the trigger, this expression gets the <array-name> array from the trigger body. 为避免在不存在数组的情况下出现故障,该表达式使用 ? 运算符:To avoid a failure if the array doesn't exist, the expression uses the ? operator:

@triggerBody()?['<array-name>']

If 操作If action

此操作为条件语句,可评估表示条件的表达式并基于条件为 true 还是 false 来运行不同的分支。This action, which is a conditional statement, evaluates an expression that represents a condition and runs a different branch based on whether the condition is true or false. 如果条件为 true,则该条件将标记为“Succeeded”状态。If the condition is true, the condition is marked with "Succeeded" status. 了解如何创建条件语句Learn how to create conditional statements.

"Condition": {
   "type": "If",
   "expression": { "<condition>" },
   "actions": {
      "<action-1>": { "<action-definition>" }
   },
   "else": {
      "actions": {
        "<action-2>": { "<action-definition" }
      }
   },
   "runAfter": {}
}
ValueValue 类型Type 说明Description
<condition> JSON 对象JSON Object 要评估的条件(可以为表达式)The condition, which can be an expression, to evaluate
<action-1> JSON 对象JSON Object 评估结果为 true 时要运行的操作The action to run when <condition> evaluates to true
<action-definition> JSON 对象JSON Object 操作的定义The definition for the action
<action-2> JSON 对象JSON Object 评估结果为 false 时要运行的操作The action to run when <condition> evaluates to false

actionselse 对象中的操作会获取以下状态:The actions in the actions or else objects get these statuses:

  • "Succeeded":运行且成功"Succeeded" when they run and succeed
  • "Failed":运行但失败"Failed" when they run and fail
  • "Skipped":未运行各自的分支"Skipped" when the respective branch doesn't run

示例Example

此条件指定当整数变量值大于零时,工作流检查网站。This condition specifies that when the integer variable has a value greater than zero, the workflow checks a website. 如果变量为零或小于零,则工作流检查另一个网站。If the variable is zero or less, the workflow checks a different website.

"Condition": {
   "type": "If",
   "expression": {
      "and": [ {
         "greater": [ "@variables('myIntegerVariable')", 0 ] 
      } ]
   },
   "actions": { 
      "HTTP - Check this website": {
         "type": "Http",
         "inputs": {
         "method": "GET",
            "uri": "http://this-url"
         },
         "runAfter": {}
      }
   },
   "else": {
      "actions": {
         "HTTP - Check this other website": {
            "type": "Http",
            "inputs": {
               "method": "GET",
               "uri": "http://this-other-url"
            },
            "runAfter": {}
         }
      }
   },
   "runAfter": {}
}

条件如何使用表达式How conditions use expressions

下面是一些示例,显示了如何在条件中使用表达式:Here are some examples that show how you can use expressions in conditions:

JSONJSON 结果Result
"expression": "@parameters('')""expression": "@parameters('<hasSpecialAction>')" 仅针对布尔表达式,该条件对任何评估结果为 true 的值进行传递。For Boolean expressions only, the condition passes for any value that evaluates to true.

若要将其他类型转换为布尔值,请使用以下函数:empty()equals()To convert other types to Boolean, use these functions: empty() or equals().

"expression": "@greater(actions('').output.value, parameters(''))" "expression": "@greater(actions('<action>').output.value, parameters('<threshold>'))" 针对比较函数,此操作仅在 的输出大于 值时运行 。For comparison functions, the action runs only when the output from <action> is more than the <threshold> value.
"expression": "@or(greater(actions('').output.value, parameters('')), less(actions('').output.value, 100))" "expression": "@or(greater(actions('<action>').output.value, parameters('<threshold>')), less(actions('<same-action>').output.value, 100))" 针对逻辑函数和创建嵌套布尔表达式,此操作在 的输出大于 值或低于 100 时运行 。For logic functions and creating nested Boolean expressions, the action runs when the output from <action> is more than the <threshold> value or under 100.
"expression": "@equals(length(actions('').outputs.errors), 0))""expression": "@equals(length(actions('<action>').outputs.errors), 0))" 可以使用数组函数检查该数组是否具有项。You can use array functions for checking whether the array has any items. 仅当 errors 数组为空时才运行该操作。The action runs when the errors array is empty.

Scope 操作Scope action

此操作按照逻辑将操作分组到范围,以便在该范围内的操作完成运行后,获取这些操作的自身状态。This action logically groups actions into scopes, which get their own status after the actions in that scope finish running. 然后,可使用该范围的状态确定是否运行其他操作。You can then use the scope's status to determine whether other actions run.

"Scope": {
   "type": "Scope",
   "actions": {
      "<inner-action-1>": {
         "type": "<action-type>",
         "inputs": { "<action-inputs>" },
         "runAfter": {}
      },
      "<inner-action-2>": {
         "type": "<action-type>",
         "inputs": { "<action-inputs>" },
         "runAfter": {}
      }
   }
}

必需Required

ValueValue 类型Type 说明Description
<inner-action-1...n><inner-action-1...n> JSON 对象JSON Object 在范围内运行的一个或多个操作One or more actions that run inside the scope
<action-inputs> JSON 对象JSON Object 每个操作的输入The inputs for each action

Switch 操作Switch action

此操作也称 switch 语句,它将其他操作组织到事例中,并为每个事例(如有默认事例,则除外)分配一个值 。This action, also known as a switch statement, organizes other actions into cases, and assigns a value to each case, except for the default case if one exists. 在运行工作流时,Switch 操作将比较表达式、对象或令牌的值与每个事例的指定值。When your workflow runs, the Switch action compares the value from an expression, object, or token against the values specified for each case. 如果 Switch 操作找到匹配事例,则工作流仅运行该事例的操作。If the Switch action finds a matching case, your workflow runs only the actions for that case. 在每次运行 Switch 操作时,仅存在一个匹配事例或无任何匹配事例存在。Each time the Switch action runs, either only one matching case exists or no matches exist. 如果不存在匹配事例,则 Switch 操作将运行默认操作。If no matches exist, the Switch action runs the default actions. 了解如何创建 switch 语句Learn how to create switch statements.

"Switch": {
   "type": "Switch",
   "expression": "<expression-object-or-token>",
   "cases": {
      "Case": {
         "actions": {
           "<action-name>": { "<action-definition>" }
         },
         "case": "<matching-value>"
      },
      "Case_2": {
         "actions": {
           "<action-name>": { "<action-definition>" }
         },
         "case": "<matching-value>"
      }
   },
   "default": {
      "actions": {
         "<default-action-name>": { "<default-action-definition>" }
      }
   },
   "runAfter": {}
}

必需Required

ValueValue 类型Type 说明Description
<expression-object-or-token> 多种多样Varies 要计算的表达式、JSON 对象或令牌The expression, JSON object, or token to evaluate
<action-name> StringString 要针对匹配事例运行的操作的名称The name of the action to run for the matching case
<action-definition> JSON 对象JSON Object 要针对匹配事例运行的操作的定义The definition for the action to run for the matching case
<matching-value> 多种多样Varies 要与计算结果比较的值The value to compare with the evaluated result

可选Optional

ValueValue 类型Type 说明Description
<default-action-name> StringString 无匹配事例存在时要运行的默认操作的名称The name of the default action to run when no matching case exists
<default-action-definition> JSON 对象JSON Object 无匹配事例存在时要运行的操作的定义The definition for the action to run when no matching case exists

示例Example

此操作定义评估答复审核请求电子邮件的人员选择了“Approve”还是“Reject”。This action definition evaluates whether the person responding to the approval request email selected the "Approve" option or the "Reject" option. 基于所作选择,Switch 操作将对匹配事例运行操作,即向答复者发送另一封电子邮件,但每个事例中的用词不同。Based on this choice, the Switch action runs the actions for the matching case, which is to send another email to the responder but with different wording in each case.

"Switch": {
   "type": "Switch",
   "expression": "@body('Send_approval_email')?['SelectedOption']",
   "cases": {
      "Case": {
         "actions": {
            "Send_an_email": { 
               "type": "ApiConnection",
               "inputs": {
                  "Body": "Thank you for your approval.",
                  "Subject": "Response received", 
                  "To": "Sophie.Owen@contoso.com"
               },
               "host": {
                  "connection": {
                     "name": "@parameters('$connections')['office365']['connectionId']"
                  }
               },
               "method": "post",
               "path": "/Mail"
            },
            "runAfter": {}
         },
         "case": "Approve"
      },
      "Case_2": {
         "actions": {
            "Send_an_email_2": { 
               "type": "ApiConnection",
               "inputs": {
                  "Body": "Thank you for your response.",
                  "Subject": "Response received", 
                  "To": "Sophie.Owen@contoso.com"
               },
               "host": {
                  "connection": {
                     "name": "@parameters('$connections')['office365']['connectionId']"
                  }
               },
               "method": "post",
               "path": "/Mail"
            },
            "runAfter": {}     
         },
         "case": "Reject"
      }
   },
   "default": {
      "actions": { 
         "Send_an_email_3": { 
            "type": "ApiConnection",
            "inputs": {
               "Body": "Please respond with either 'Approve' or 'Reject'.",
               "Subject": "Please respond", 
               "To": "Sophie.Owen@contoso.com"
            },
            "host": {
               "connection": {
                  "name": "@parameters('$connections')['office365']['connectionId']"
               }
            },
            "method": "post",
            "path": "/Mail"
         },
         "runAfter": {} 
      }
   },
   "runAfter": {
      "Send_approval_email": [ 
         "Succeeded"
      ]
   }
}

Until 操作Until action

此循环操作包含在指定条件为 true 之前一直运行的操作。This loop action contains actions that run until the specified condition is true. 在运行所有其他操作后,此循环会最后检查此条件。The loop checks the condition as the last step after all other actions have run. 可在 "actions" 对象中包含多个操作,且该操作必须至少定义一个限制。You can include more than one action in the "actions" object, and the action must define at least one limit. 了解如何创建“until”循环Learn how to create "until" loops.

 "Until": {
   "type": "Until",
   "actions": {
      "<action-name>": {
         "type": "<action-type>",
         "inputs": { "<action-inputs>" },
         "runAfter": {}
      },
      "<action-name>": {
         "type": "<action-type>",
         "inputs": { "<action-inputs>" },
         "runAfter": {}
      }
   },
   "expression": "<condition>",
   "limit": {
      "count": <loop-count>,
      "timeout": "<loop-timeout>"
   },
   "runAfter": {}
}
ValueValue 类型Type 说明Description
<action-name> StringString 要在循环内运行的操作的名称The name for the action you want to run inside the loop
<action-type> StringString 要运行的操作类型The action type you want to run
<action-inputs> 各种Various 要运行的操作的输入The inputs for the action to run
<condition> StringString 当循环中的所有操作都运行完成后要计算的条件或表达式The condition or expression to evaluate after all the actions in the loop finish running
<loop-count> IntegerInteger 针对操作可运行的最大循环数的限制。The limit on the most number of loops that the action can run. 有关默认限制和最大限制的详细信息,请参阅 Azure 逻辑应用的限制和配置For more information about the default limit and maximum limit, see Limits and configuration for Azure Logic Apps.
<loop-timeout> StringString 针对循环可运行的最长时间的限制。The limit on the longest time that the loop can run. 默认 timeout 值为 PT1H,即要求的 ISO 8601 格式The default timeout value is PT1H, which is the required ISO 8601 format.

示例Example

此循环操作定义向指定 URL 发送一个 HTTP 请求,直到满足以下某个条件:This loop action definition sends an HTTP request to the specified URL until one of these conditions is met:

  • 该请求获得一个含有“200 OK”状态代码的响应。The request gets a response with the "200 OK" status code.
  • 该循环已运行 60 次。The loop has run 60 times.
  • 该循环已运行一小时。The loop has run for one hour.
 "Run_until_loop_succeeds_or_expires": {
    "type": "Until",
    "actions": {
        "HTTP": {
            "type": "Http",
            "inputs": {
                "method": "GET",
                "uri": "http://myurl"
            },
            "runAfter": {}
        }
    },
    "expression": "@equals(outputs('HTTP')['statusCode'], 200)",
    "limit": {
        "count": 60,
        "timeout": "PT1H"
    },
    "runAfter": {}
}

Webhook 和订阅Webhooks and subscriptions

基于 Webhook 的触发器和操作不会定期检查终结点,而是等待这些终结点中的指定事件或数据。Webhook-based triggers and actions don't regularly check endpoints, but wait for specific events or data at those endpoints instead. 这些触发器和操作通过提供一个回叫 URL 来订阅终结点,终结点可向该 URL 发送响应 。These triggers and actions subscribe to the endpoints by providing a callback URL where the endpoint can send responses.

当工作流出现任何形式的更改时,都将发生 subscribe 调用,例如续订凭据或触发器或操作的输入参数发生更改时。The subscribe call happens when the workflow changes in any way, for example, when credentials are renewed, or when the input parameters change for a trigger or action. 该调用使用与标准 HTTP 操作相同的参数。This call uses the same parameters as standard HTTP actions.

当操作使得触发器或操作无效时,会自动发生 unsubscribe 调用,例如:The unsubscribe call automatically happens when an operation makes the trigger or action invalid, for example:

  • 删除或禁用触发器。Deleting or disabling the trigger.
  • 删除或禁用工作流。Deleting or disabling the workflow.
  • 删除或禁用订阅。Deleting or disabling the subscription.

为支持这些调用,@listCallbackUrl() 表达式为此触发器或操作返回唯一的“回叫 URL”。To support these calls, the @listCallbackUrl() expression returns a unique "callback URL" for the trigger or action. 此 URL 代表使用服务 REST API 的终结点的唯一标识符。This URL represents a unique identifier for the endpoints that use the service's REST API. 此函数的参数与 webhook 触发器或操作相同。The parameters for this function are the same as the webhook trigger or action.

更改异步持续时间Change asynchronous duration

对于触发器和操作,均可通过添加 limit.timeout 属性的方式将异步模式的持续时间限制为指定时间间隔。For both triggers and actions, you can limit the duration for the asynchronous pattern to a specific time interval by adding the limit.timeout property. 这样,如果该指定间隔结束时操作尚未完成,则会使用 ActionTimedOut 代码将操作的状态标记为 CancelledThat way, if the action hasn't finished when the interval lapses, the action's status is marked as Cancelled with the ActionTimedOut code. timeout 属性使用 ISO 8601 格式The timeout property uses ISO 8601 format.

"<trigger-or-action-name>": {
   "type": "Workflow | Webhook | Http | ApiConnectionWebhook | ApiConnection",
   "inputs": {},
   "limit": {
      "timeout": "PT10S"
   },
   "runAfter": {}
}

运行时配置设置Runtime configuration settings

可通过向触发器或操作定义中添加以下 runtimeConfiguration 属性来更改触发器和操作的默认运行时行为。You can change the default runtime behavior for triggers and actions by adding these runtimeConfiguration properties to the trigger or action definition.

属性Property 类型Type 说明Description 触发器或操作Trigger or action
runtimeConfiguration.concurrency.runs IntegerInteger 更改可同时(并发或并行)运行的工作流实例数的默认限制Change the default limit on the number of workflow instances that can run at the same time (concurrently or in parallel). 调整此值有助于限制后端系统接收的请求数。Adjusting this value can help limit the number of requests that backend systems receive.

runs 属性设置为 1 与将 operationOptions 属性设置为 SingleInstance 的作用相同。Setting the runs property to 1 works the same way as setting the operationOptions property to SingleInstance. 可以设置其中任一属性,但不能同时设置二者。You can set either property, but not both.

若要更改此默认限制,请参阅更改触发器并发按顺序触发实例To change the default limit, see Change trigger concurrency or Trigger instances sequentially.

所有触发器All triggers
runtimeConfiguration.concurrency.maximumWaitingRuns IntegerInteger 更改当逻辑应用已运行最大并发实例数时必须等待运行的工作流实例数的默认限制Change the default limit on the number of workflow instances that must wait to run when your logic app is already running the maximum concurrent instances.

若要更改此默认限制,请参阅更改等待的运行限制To change the default limit, see Change waiting runs limit.

所有触发器All triggers
runtimeConfiguration.concurrency.repetitions IntegerInteger 更改可同时(并发或并行)运行的“for each”循环迭代数的默认限制Change the default limit on the number of "for each" loop iterations that can run at the same time (concurrently or in parallel).

repetitions 属性设置为 1 与将 operationOptions 属性设置为 SingleInstance 的作用相同。Setting the repetitions property to 1 works the same way as setting the operationOptions property to SingleInstance. 可以设置其中任一属性,但不能同时设置二者。You can set either property, but not both.

若要更改默认限制,请参阅更改“for each”并发按顺序运行“for each”循环To change the default limit, see Change "for each" concurrency or Run "for each" loops sequentially.

操作:Action:

ForeachForeach

runtimeConfiguration.paginationPolicy.minimumItemCount IntegerInteger 对于支持且已启用分页的特定操作,此值指定要检索的最小结果数。For specific actions that support and have pagination turned on, this value specifies the minimum number of results to retrieve.

若要启用分页,请参阅使用分页获取批量数据、项或结果To turn on pagination, see Get bulk data, items, or results by using pagination

操作:VariedAction: Varied
runtimeConfiguration.secureData.properties ArrayArray 在许多触发器和操作中,这些设置会向逻辑应用的运行历史记录隐藏输入和/或输出。On many triggers and actions, these settings hide inputs, outputs, or both from the logic app's run history.

若要详细了解如何保护此数据,请参阅在运行历史记录中隐藏输入和输出To learn more about safeguarding this data, see Hide inputs and outputs from run history.

大多数触发器和操作Most triggers and actions
runtimeConfiguration.staticResult JSON 对象JSON Object 对于支持且已启用静态结果设置的操作,staticResult 对象包含以下特性:For actions that support and have the static result setting turned on, the staticResult object has these attributes:

- name,引用当前操作的静态结果定义名称,该名称显示在逻辑应用工作流的 definition 特性中的 staticResults 特性内。- name, which references the current action's static result definition name, which appears inside the staticResults attribute in your logic app workflow's definition attribute. 有关详细信息,请参阅静态结果 - 工作流定义语言的架构参考For more information, see Static results - Schema reference for Workflow Definition Language.

- staticResultOptions,指定当前操作的静态结果是否为 Enabled- staticResultOptions, which specifies whether static results are Enabled or not for the current action.

若要启用静态结果,请参阅通过设置静态结果来使用模拟数据测试逻辑应用To turn on static results, see Test logic apps with mock data by setting up static results

操作:VariedAction: Varied

操作选项Operation options

可通过触发器或操作定义中的以下 operationOptions 属性更改触发器和操作的默认行为。You can change the default behavior for triggers and actions with the operationOptions property in trigger or action definition.

操作选项Operation option 类型Type 说明Description 触发器或操作Trigger or action
DisableAsyncPattern StringString 以同步方式而非异步方式运行基于 HTTP 的操作。Run HTTP-based actions synchronously, rather than asynchronously.

若要设置此选项,请参阅同步运行操作To set this option, see Run actions synchronously.

操作:Actions:

ApiConnection,ApiConnection,
HTTPHTTP,
响应Response

OptimizedForHighThroughput StringString 将针对每 5 分钟的操作执行数的默认限制更改为最大限制Change the default limit on the number of action executions per 5 minutes to the maximum limit.

若要设置此选项,请参阅在高吞吐量模式下运行To set this option, see Run in high throughput mode.

所有操作All actions
Sequential StringString 每次运行一个“for each”循环迭代,而不是同时并行运行所有迭代。Run "for each" loop iterations one at a time, rather than all at the same time in parallel.

此选项与将 runtimeConfiguration.concurrency.repetitions 属性设置为 1 的作用相同。This option works the same way as setting the runtimeConfiguration.concurrency.repetitions property to 1. 可以设置其中任一属性,但不能同时设置二者。You can set either property, but not both.

若要设置此选项,请参阅按顺序运行“for each”循环To set this option, see Run "for each" loops sequentially.

操作:Action:

ForeachForeach

SingleInstance StringString 按顺序对每个逻辑应用实例运行此触发器,并在等待上一个活动运行完成后,再触发下一个逻辑应用实例。Run the trigger for each logic app instance sequentially and wait for the previously active run to finish before triggering the next logic app instance.

此选项与将 runtimeConfiguration.concurrency.runs 属性设置为 1 的作用相同。This option works the same way as setting the runtimeConfiguration.concurrency.runs property to 1. 可以设置其中任一属性,但不能同时设置二者。You can set either property, but not both.

若要设置此选项,请参阅按顺序触发实例To set this option, see Trigger instances sequentially.

所有触发器All triggers

更改触发器并发Change trigger concurrency

默认情况下,逻辑应用工作流实例全部(以并发或并行方式)同时运行。By default, logic app workflow instances all run at the same time (concurrently or in parallel). 此行为意味着,每个触发器实例会在上一个处于活动状态的工作流实例完成运行之前触发。This behavior means that each trigger instance fires before the previously active workflow instance finishes running. 但是,并发运行的实例数有一个默认限制However, the number of concurrently running instances has a default limit. 当并发运行的工作流实例的数量达到此限制时,任何其他新实例都必须等待运行。When the number of concurrently running workflow instances reaches this limit, any other new instances must wait to run. 此限制可控制后端系统接收的请求数。This limit helps control the number of requests that backend systems receive.

开启触发器的并发控制后,触发器实例将并行运行,直至达到默认限制When you turn on the trigger's concurrency control, trigger instances run in parallel up to the default limit. 若要更改此默认并发限制,可使用代码视图编辑器或逻辑应用设计器,因为通过设计器更改并发设置会添加或更新基础触发器定义中的 runtimeConfiguration.concurrency.runs 属性,反之亦然。To change this default concurrency limit, you can use either the code view editor or Logic Apps Designer because changing the concurrency setting through the designer adds or updates the runtimeConfiguration.concurrency.runs property in the underlying trigger definition and vice versa. 此属性控制可并行运行的新工作流实例的最大数目。This property controls the maximum number of new workflow instances that can run in parallel.

下面是对于何时需要在触发器上启用并发的一些考量:Here are some considerations for when you want to enable concurrency on a trigger:

  • 启用并发后,会显著降低解除数组批处理时的 SplitOn 限制When concurrency is enabled, the SplitOn limit is significantly reduced for debatching arrays. 如果项数超过此限制,会禁用 SplitOn 功能。If the number of items exceeds this limit, the SplitOn capability is disabled.

  • 启用并发控制后,无法禁用并发。You can't disable concurrency after you enable the concurrency control.

  • 启用并发后,会显著降低解除数组批处理时的 SplitOn 限制When concurrency is enabled, the SplitOn limit is significantly reduced for debatching arrays. 如果项数超过此限制,会禁用 SplitOn 功能。If the number of items exceeds this limit, the SplitOn capability is disabled.

  • 启用并发后,长时间运行的逻辑应用实例可能会导致新的逻辑应用实例进入等待状态。When concurrency is enabled, a long-running logic app instance might cause new logic app instances to enter a waiting state. 此状态会阻止 Azure 逻辑应用创建新实例,即使并发运行次数小于指定的最大并发运行次数,也会发生这种情况。This state prevents Azure Logic Apps from creating new instances and happens even when the number of concurrent runs is less than the specified maximum number of concurrent runs.

    • 若要中断此状态,请取消仍在运行的最早实例。To interrupt this state, cancel the earliest instances that are still running.

      1. 在逻辑应用的菜单中,选择“概述”。On your logic app's menu, select Overview.

      2. 在“运行历史记录”部分中,选择仍在运行的最早实例,例如:In the Runs history section, select the earliest instance that is still running, for example:

        选择正在运行的最早实例

        提示

        若要仅查看仍在运行的实例,请打开“全部”列表,然后选择“正在运行”。To view only instances that are still running, open the All list, and select Running.

      3. 在“逻辑应用运行”下,选择“取消运行”。Under Logic app run, select Cancel run.

        查找正在运行的最早实例

    • 若要避免这种可能性,请为任何可能阻止这些运行的操作添加超时。To work around this possibility, add a timeout to any action that might hold up these runs. 如果使用的是代码编辑器,请参阅更改异步持续时间If you're working in the code editor, see Change asynchronous duration. 否则,如果使用的是设计器,请执行以下步骤:Otherwise, if you're using the designer, follow these steps:

      1. 在逻辑应用中要添加超时的操作的右上角选择省略号 ( ... ) 按钮,然后选择“设置”。In your logic app, on the action where you want to add a timeout, in the upper-right corner, select the ellipses (...) button, and then select Settings.

        打开操作设置

      2. 在“超时”下,指定 ISO 8601 格式的超时持续时间。Under Timeout, specify the timeout duration in ISO 8601 format.

        指定超时持续时间

  • 若要按顺序运行逻辑应用,请使用代码视图编辑器或设计器将触发器的并发度设置为 1To run your logic app sequentially, set the trigger's concurrency to 1 either by using the code view editor or the designer. 请确保不要在代码视图编辑器中将触发器的 operationOptions 属性也设置为 SingleInstanceMake sure that you don't also set the trigger's operationOptions property to SingleInstance in the code view editor. 否则会出现验证错误。Otherwise, you get a validation error. 有关详细信息,请参阅按顺序触发实例For more information, see Trigger instances sequentially.

在代码视图中编辑Edit in code view

在基础触发器定义中添加 runtimeConfiguration.concurrency.runs 属性,该属性可以有一个从 150 范围内的值。In the underlying trigger definition, add the runtimeConfiguration.concurrency.runs property, which can have a value that ranges from 1 to 50.

以下示例将并发运行数限制为 10 个实例:Here is an example that limits concurrent runs to 10 instances:

"<trigger-name>": {
   "type": "<trigger-name>",
   "recurrence": {
      "frequency": "<time-unit>",
      "interval": <number-of-time-units>,
   },
   "runtimeConfiguration": {
      "concurrency": {
         "runs": 10
      }
   }
}

有关详细信息,请参阅运行时配置设置For more information, see Runtime configuration settings.

在逻辑应用设计器中编辑Edit in Logic Apps Designer

  1. 在触发器的右上角,选择省略号 ( ... ) 按钮,然后选择“设置”。In the trigger's upper-right corner, select the ellipses (...) button, and then select Settings.

  2. 在“并发控制”下,将“限制”设为“开启” 。Under Concurrency Control, set Limit to On.

  3. 将“并行度”滑块拖到所需值处。Drag the Degree of Parallelism slider to the value you want. 若要按顺序运行逻辑应用,请将滑块值拖到 1。To run your logic app sequentially, drag the slider value to 1.

更改“for each”并发Change "for each" concurrency

默认情况下,“for each”循环迭代全部同时(以并发或并行方式)运行。By default, "for each" loop iterations all run at the same time (concurrently or in parallel). 此行为意味着每个迭代在上一个迭代完成运行之前开始运行。This behavior means that each iteration starts running before the previous iteration finishes running. 但是,并发运行的迭代数有一个默认限制However, the number of concurrently running iterations has a default limit. 当并发运行的迭代的数量达到此限制时,任何其他迭代都必须等待运行。When the number of concurrently running iterations reaches this limit, any other iterations must wait to run.

若要更改此默认限制,可使用代码视图编辑器或逻辑应用设计器,因为通过设计器更改并发设置会添加或更新基础“for each”操作定义中的 runtimeConfiguration.concurrency.repetitions 属性,反之亦然。To change the default limit, you can use either the code view editor or Logic Apps Designer because changing the concurrency setting through the designer adds or updates the runtimeConfiguration.concurrency.repetitions property in the underlying "for each" action definition and vice versa. 此属性控制可并行运行的最大迭代数。This property controls the maximum number of iterations that can run in parallel.

备注

如果通过设计器或代码视图编辑器将“for each”操作设为按顺序运行,请勿在代码视图编辑器中将此操作的 operationOptions 属性设置为 SequentialIf you set the "for each" action to run sequentially either by using the designer or the code view editor, don't set the action's operationOptions property to Sequential in the code view editor. 否则会出现验证错误。Otherwise, you get a validation error. 有关详细信息,请参阅按顺序运行“for each”循环For more information, see Run "for each" loops sequentially.

在代码视图中编辑Edit in code view

在基础“for each”定义中添加或更新 runtimeConfiguration.concurrency.repetitions 属性,该属性可以有一个从 150 范围内的值。In the underlying "for each" definition, add or update the runtimeConfiguration.concurrency.repetitions property, which can have a value that ranges from 1 and 50.

以下示例将并发运行数限制为 10 个迭代:Here is an example that limits concurrent runs to 10 iterations:

"For_each" {
   "type": "Foreach",
   "actions": { "<actions-to-run>" },
   "foreach": "<for-each-expression>",
   "runAfter": {},
   "runtimeConfiguration": {
      "concurrency": {
         "repetitions": 10
      }
   }
}

有关详细信息,请参阅运行时配置设置For more information, see Runtime configuration settings.

在逻辑应用设计器中编辑Edit in Logic Apps Designer

  1. 在“For each”操作中,从右上角选择省略号 ( ... ) 按钮,然后选择“设置” 。In the For each action, from the upper-right corner, select the ellipses (...) button, and then select Settings.

  2. 在“并发控制”下,将“并发控制”设置为“开启” 。Under Concurrency Control, set Concurrency Control to On.

  3. 将“并行度”滑块拖到所需值处。Drag the Degree of Parallelism slider to the value you want. 若要按顺序运行逻辑应用,请将滑块值拖到 1。To run your logic app sequentially, drag the slider value to 1.

更改等待的运行限制Change waiting runs limit

默认情况下,逻辑应用工作流实例全部(以并发或并行方式)同时运行。By default, logic app workflow instances all run at the same time (concurrently or in parallel). 此行为意味着,每个触发器实例会在上一个处于活动状态的工作流实例完成运行之前触发。This behavior means that each trigger instance fires before the previously active workflow instance finishes running. 但是,并发运行的实例数有一个默认限制However, the number of concurrently running instances has a default limit. 当并发运行的工作流实例的数量达到此限制时,任何其他新实例都必须等待运行。When the number of concurrently running workflow instances reaches this limit, any other new instances must wait to run.

等待的运行数也有一个默认限制The number of waiting runs also has a default limit. 当等待的运行数达到此限制时,逻辑应用引擎将不再接受新的运行。When the number of waiting runs reaches this limit, the Logic Apps engine no longer accepts new runs. 请求和 webhook 触发器返回 429 错误,并且重复的触发器会开始跳过轮询尝试。Request and webhook triggers return 429 errors, and recurring triggers start skipping polling attempts.

你不仅可以更改触发器并发的默认限制,还可以更改等待的运行数的默认限制。Not only can you change the default limit on trigger concurrency, but you can also change the default limit on waiting runs. 在基础触发器定义中添加 runtimeConfiguration.concurrency.maximumWaitingRuns 属性,该属性可以有一个从 1100 范围内的值。In the underlying trigger definition, add the runtimeConfiguration.concurrency.maximumWaitingRuns property, which can have a value that ranges from 1 to 100.

"<trigger-name>": {
   "type": "<trigger-name>",
   "recurrence": {
      "frequency": "<time-unit>",
      "interval": <number-of-time-units>,
   },
   "runtimeConfiguration": {
      "concurrency": {
         "maximumWaitingRuns": 50
      }
   }
}

有关详细信息,请参阅运行时配置设置For more information, see Runtime configuration settings.

按顺序触发实例Trigger instances sequentially

若要仅在上一个实例完成运行后才运行每个逻辑应用工作流实例,请将此触发器设为按顺序运行。To run each logic app workflow instance only after the previous instance finishes running, set the trigger to run sequentially. 可使用代码视图编辑器或逻辑应用设计器,因为通过设计器更改并发设置还会添加或更新基础触发器定义中的 runtimeConfiguration.concurrency.runs 属性,反之亦然。You can use either the code view editor or Logic Apps Designer because changing the concurrency setting through designer also adds or updates the runtimeConfiguration.concurrency.runs property in the underlying trigger definition and vice versa.

备注

如果通过设计器或代码视图编辑器将触发器设为按顺序运行,请勿在代码视图编辑器中将触发器的 operationOptions 属性设置为 SequentialWhen you set a trigger to run sequentially either by using the designer or the code view editor, don't set the trigger's operationOptions property to Sequential in the code view editor. 否则会出现验证错误。Otherwise, you get a validation error.

在代码视图中编辑Edit in code view

在触发器定义中,设置以下任一属性,但不可同时设置二者。In the trigger definition, set either of these properties, but not both.

runtimeConfiguration.concurrency.runs 属性设为 1Set the runtimeConfiguration.concurrency.runs property to 1:

"<trigger-name>": {
   "type": "<trigger-name>",
   "recurrence": {
      "frequency": "<time-unit>",
      "interval": <number-of-time-units>,
   },
   "runtimeConfiguration": {
      "concurrency": {
         "runs": 1
      }
   }
}

-or-

operationOptions 属性设为 SingleInstanceSet the operationOptions property to SingleInstance:

"<trigger-name>": {
   "type": "<trigger-name>",
   "recurrence": {
      "frequency": "<time-unit>",
      "interval": <number-of-time-units>,
   },
   "operationOptions": "SingleInstance"
}

有关详细信息,请参阅运行时配置设置操作选项For more information, see Runtime configuration settings and Operation options.

在逻辑应用设计器中编辑Edit in Logic Apps Designer

  1. 在触发器的右上角,选择省略号 ( ... ) 按钮,然后选择“设置”。In the trigger's upper-right corner, select the ellipses (...) button, and then select Settings.

  2. 在“并发控制”下,将“限制”设为“开启” 。Under Concurrency Control, set Limit to On.

  3. 将“并行度”滑块拖到数字 1Drag the Degree of Parallelism slider to the number 1.

按顺序运行“for each”循环Run "for each" loops sequentially

若要仅在上一迭代完成运行后才运行“for each”循环迭代,请将“for each”操作设为按顺序运行。To run a "for each" loop iteration only after the previous iteration finishes running, set the "for each" action to run sequentially. 可使用代码视图编辑器或逻辑应用设计器,因为通过设计器更改操作的并发还会添加或更新基础操作定义中的 runtimeConfiguration.concurrency.repetitions 属性,反之亦然。You can use either the code view editor or Logic Apps Designer because changing the action's concurrency through designer also adds or updates the runtimeConfiguration.concurrency.repetitions property in the underlying action definition and vice versa.

备注

如果通过设计器或代码视图编辑器将“for each”操作设为按顺序运行,请勿在代码视图编辑器中将此操作的 operationOptions 属性设置为 SequentialWhen you set a "for each" action to run sequentially either by using the designer or code view editor, don't set the action's operationOptions property to Sequential in the code view editor. 否则会出现验证错误。Otherwise, you get a validation error.

在代码视图中编辑Edit in code view

在操作定义中,设置以下任一属性,但不可同时设置二者。In the action definition, set either of these properties, but not both.

runtimeConfiguration.concurrency.repetitions 属性设为 1Set the runtimeConfiguration.concurrency.repetitions property to 1:

"For_each" {
   "type": "Foreach",
   "actions": { "<actions-to-run>" },
   "foreach": "<for-each-expression>",
   "runAfter": {},
   "runtimeConfiguration": {
      "concurrency": {
         "repetitions": 1
      }
   }
}

-or-

operationOptions 属性设为 SequentialSet the operationOptions property to Sequential:

"For_each" {
   "type": "Foreach",
   "actions": { "<actions-to-run>" },
   "foreach": "<for-each-expression>",
   "runAfter": {},
   "operationOptions": "Sequential"
}

有关详细信息,请参阅运行时配置设置操作选项For more information, see Runtime configuration settings and Operation options.

在逻辑应用设计器中编辑Edit in Logic Apps Designer

  1. 在“For each”操作的右上角,选择省略号 ( ... ) 按钮,然后选择“设置” 。In the For each action's upper-right corner, select the ellipses (...) button, and then select Settings.

  2. 在“并发控制”下,将“并发控制”设置为“开启” 。Under Concurrency Control, set Concurrency Control to On.

  3. 将“并行度”滑块拖到数字 1Drag the Degree of Parallelism slider to the number 1.

在同步操作模式下运行操作Run actions in a synchronous operation pattern

默认情况下,Azure 逻辑应用中的 HTTP 操作和 APIConnection 操作遵循标准异步操作模式,而响应操作则遵循“同步操作模式”。By default, the HTTP action and APIConnection actions in Azure Logic Apps follow the standard asynchronous operation pattern, while the Response action follows the synchronous operation pattern. 异步模式指定在操作调用指定的终结点、服务、系统或 API 或向其发送请求后,接收方立即返回“202 已接受”响应。The asynchronous pattern specifies that after an action calls or sends a request to the specified endpoint, service, system, or API, the receiver immediately returns a "202 ACCEPTED" response. 此代码确认接收方已接受请求,但尚未完成处理。This code confirms that the receiver accepted the request but hasn't finished processing. 响应可以包括一个指定了 URL 和刷新 ID 的 location 标头,调用方可以使用该标头来持续轮询或检查异步请求的状态,直到接收方停止处理并返回“200 正常”成功响应或其他非 202 响应。The response can include a location header that specifies the URL and a refresh ID that the caller can use to continually poll or check the status for the asynchronous request until the receiver stops processing and returns a "200 OK" success response or other non-202 response. 有关详细信息,请参阅异步微服务集成强制实施微服务自治For more information, see Asynchronous microservice integration enforces microservice autonomy.

  • 在逻辑应用设计器中,HTTP 操作、APIConnection 操作和“响应”操作具有“异步模式”设置。In the Logic App Designer, the HTTP action, APIConnection actions, and Response action have the Asynchronous Pattern setting. 启用后,此设置指定调用方不等待处理完成即可继续执行下一操作,但需继续检查状态直到处理停止。When enabled, this setting specifies that the caller doesn't wait for processing to finish and can move on to the next action but continues checking the status until processing stops. 如果禁用,则此设置指定调用方需等待处理完成才能继续执行下一操作。If disabled, this setting specifies that the caller waits for processing to finish before moving on to the next action. 若要查找此设置,请执行以下步骤:To find this setting, follow these steps:

    1. 在 HTTP 操作的标题栏上,选择省略号 ( ... ) 按钮,这将打开操作的设置。On the HTTP action's title bar, select the ellipses (...) button, which opens the action's settings.

    2. 找到“异步模式”设置。Find the Asynchronous Pattern setting.

      “异步模式”设置

  • 在操作的基础 JavaScript 对象表示法 (JSON) 定义中,HTTP 操作和 APIConnection 操作隐式遵循异步操作模式。In the action's underlying JavaScript Object Notation (JSON) definition, the HTTP action and APIConnection actions implicitly follow the asynchronous operation pattern.

在某些情况下,你可能希望操作改为遵循同步模式。In some scenarios, you might want an action to follow the synchronous pattern instead. 例如,当你使用 HTTP 操作时,你可能希望:For example, when you use the HTTP action, you might want to:

在这些情况下,可以使用以下选项使操作以同步模式运行:In these cases, you can make an action run synchronously by using these options:

关闭“异步模式”设置Turn off Asynchronous Pattern setting

  1. 在逻辑应用设计器的操作的标题栏上,选择省略号 ( ... ) 按钮,这将打开操作的设置。In the Logic App Designer, on the action's title bar, select the ellipses (...) button, which opens the action's settings.

  2. 找到“异步模式”设置,关闭此设置(如果已启用),然后选择“完成”。Find the Asynchronous Pattern setting, turn the setting to Off if enabled, and select Done.

    关闭“异步模式”设置

在操作的 JSON 定义中禁用异步模式Disable asynchronous pattern in action's JSON definition

在操作的基础 JSON 定义中,在操作的 "inputs" 节下添加“operationOptions”属性并将其设置为 "DisableAsyncPattern",例如:In the action's underlying JSON definition, add and set the "operationOptions" property to "DisableAsyncPattern" under the action's "inputs" section, for example:

"<some-long-running-action>": {
   "type": "Http",
   "inputs": { "<action-inputs>" },
   "operationOptions": "DisableAsyncPattern",
   "runAfter": {}
}

在高吞吐量模式下运行Run in high throughput mode

对于单个逻辑应用定义,每 5 分钟执行的操作数具有默认限制For a single logic app definition, the number of actions that execute every 5 minutes has a default limit. 若要将此限制提高到可能的最大值,请将 operationOptions 属性设为 OptimizedForHighThroughputTo raise this limit to the maximum possible, set the operationOptions property to OptimizedForHighThroughput. 此设置将逻辑应用置于“高吞吐量”模式之中。This setting puts your logic app into "high throughput" mode.

备注

高吞吐量模式处于预览状态。High throughput mode is in preview. 此外,还可根据需要在多个逻辑应用之间分配工作负荷。You can also distribute a workload across more than one logic app as necessary.

"<action-name>": {
   "type": "<action-type>",
   "inputs": { "<action-inputs>" },
   "operationOptions": "OptimizedForHighThroughput",
   "runAfter": {}
}

对触发器和操作进行身份验证Authenticate triggers and actions

HTTP 和 HTTPS 终结点支持不同类型的身份验证。HTTP and HTTPS endpoints support different kinds of authentication. 根据用于发出访问这些终结点的出站调用或请求的触发器或操作,可以从各种不同的身份验证类型中进行选择。Based on the trigger or action that you use to make outbound calls or requests to access these endpoints, you can select from different ranges of authentication types. 有关详细信息,请参阅针对出站调用添加身份验证For more information, see Add authentication to outbound calls.

后续步骤Next steps