You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Terraform为Azure Logic Apps配置多个串行执行的自定义动作

解决方法

Logic App中控制动作执行顺序的核心参数是自定义动作配置里的runAfter字段,你当前两个动作的runAfter都为空,意味着两个动作都会在HTTP触发器执行完成后同时启动,因此出现并行运行的情况。

要实现串行执行,只需要按执行顺序为每个后续动作指定前序依赖即可:

  1. 第一个自定义动作example-action配置为在HTTP触发器成功后执行
  2. 第二个自定义动作example-action2配置为在第一个自定义动作成功后执行

修改后的核心代码片段

第一个自定义动作配置

resource "azurerm_logic_app_action_custom" "example" {
  name         = "example-action"
  logic_app_id = azurerm_logic_app_workflow.example.id

  body = <<BODY
{
    "description": "A variable to configure the auto expiration age in days. Configured in negative number. Default is -30 (30 days old).",
    "inputs": {
        "variables": [
            {
                "name": "ExpirationAgeInDays",
                "type": "Integer",
                "value": -30
            }
        ]
    },
    "runAfter": {
        "some-http-trigger": [
            "Succeeded"
        ]
    },
    "type": "InitializeVariable"
}
BODY
}

第二个自定义动作配置

resource "azurerm_logic_app_action_custom" "example2" {
  name         = "example-action2"
  logic_app_id = azurerm_logic_app_workflow.example.id

  body = <<BODY
{
    "description": "A variable to configure the auto expiration age in days. Configured in negative number. Default is -30 (30 days old).",
    "inputs": {
        "variables": [
            {
                "name": "ExpirationAgeInDays2",
                "type": "Integer",
                "value": -30
            }
        ]
    },
    "runAfter": {
        "example-action": [
            "Succeeded"
        ]
    },
    "type": "InitializeVariable"
}
BODY
}

配置说明

runAfter字段的键为前序步骤的名称,值为触发当前步骤执行的前序步骤状态,常用状态包括Succeeded(成功后执行)、Failed(失败后执行)、Skipped(跳过后执行)。按上述配置修改后,动作就会按「HTTP触发器→第一个变量初始化→第二个变量初始化」的顺序串行执行。

操作界面示意:
操作界面示意

内容的提问来源于stack exchange,提问作者Kenny_I

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 01:45:04