【问题标题】:Can I chain multiple actions for every item in a repeat list我可以为重复列表中的每个项目链接多个操作吗
【发布时间】:2016-01-25 12:42:12
【问题描述】:

尝试了一个简单的逻辑应用程序,我可以在其中从 API 检索列表。使用重复列表功能,我能够为列表中的每个项目发送一封电子邮件。

但我真的希望能够为列表中的每个项目执行多个链接的操作/步骤……这不可能吗?我知道我可以有多个操作/步骤来为同一列表中的每个项目执行某些操作...但这些操作/步骤并未像以下代码中那样链接:

    "triggers": {
    "recurrence": {
        "recurrence": {
            "frequency": "Day",
            "interval": 1
        },
        "type": "Recurrence"
    }
},
"actions": {
    "http": {
        "type": "Http",
        "inputs": {
            "method": "GET",
            "uri": "https://example.com/pcme/3/7",
            "headers": {
                "Content-Type": "application/json",
                "Authorization": "Basic my auth"
            }
        },
        "conditions": []
    },
    "office365connector": {
        "type": "ApiApp",
        "inputs": {
            "apiVersion": "2015-01-14",
            "host": {
                "id": "/subscriptions/xxxx/resourcegroups/workflows/providers/Microsoft.AppService/apiapps/office365connector",
                "gateway": "https://workflowsxxxxxx.azurewebsites.net"
            },
            "operation": "SendMail",
            "parameters": {
                "message": {
                    "To": "some-email@me.com",
                    "Subject": "@repeatItem().activationCode"
                }
            },
            "authentication": {
                "type": "Raw",
                "scheme": "Zumo",
                "parameter": "@parameters('/subscriptions/xxxxxx/resourcegroups/workflows/providers/Microsoft.AppService/apiapps/office365connector/token')"
            }
        },
        "repeat": "@body('http')",
        "conditions": [
            {
                "expression": "@equals(actions('http').status, 'Succeeded')"
            }
        ]
    },
    "office365connector0": {
        "type": "ApiApp",
        "inputs": {
            "apiVersion": "2015-01-14",
            "host": {
                "id": "/subscriptions/xxxx/resourcegroups/workflows/providers/Microsoft.AppService/apiapps/office365connector",
                "gateway": "https://workflowsdxxxx.azurewebsites.net"
            },
            "operation": "SendMail",
            "parameters": {
                "message": {
                    "To": "some-email@gmail.com",
                    "Subject": "@repeatItem().cardNumber"
                }
            },
            "authentication": {
                "type": "Raw",
                "scheme": "Zumo",
                "parameter": "@parameters('/subscriptions/xxxxx/resourcegroups/workflows/providers/Microsoft.AppService/apiapps/office365connector/token')"
            }
        },
        "repeat": "@body('http')",
        "conditions": [
            {
                "expression": "@equals(actions('http').status, 'Succeeded')"
            }
        ]
    }

感谢您的帮助。

问候

【问题讨论】:

    标签: azure-logic-apps


    【解决方案1】:

    在列表中的每个项目上链接操作的一个选项是使用嵌套逻辑应用。

    您的设置方式是创建一个子逻辑应用,其中包含您希望应用于每个单独项目的一系列操作。然后,父逻辑应用将使用工作流操作类型来调用子逻辑应用的每个重复项的运行。

    然后您的父工作流将被定义为

    "actions": {
      "http": {
        "type": "Http",
        "inputs": {
          "method": "GET",
          "uri": "https://example.com/pcme/3/7",
          "headers": {
            "Content-Type": "application/json",
            "Authorization": "Basic my auth"
          }
        },
        "conditions": []
      },
      "processEachItem" : {
        "type": "workflow",
        "inputs": { 
          "uri": <child flow direct invoke uri>,
          "apiVersion": "2015-02-01-preview",
          "trigger": {
              "name" : "runNow",
              "outputs": { "item": "@repeatItem()" }
            },
          "authentication": {
            "type" : " Basic",
            "username" : "myKey",
            "password" : "xxxxxxxxxxxxxxx",
          },
          "repeat": "@body('http')",
        }
      }
    }
    

    以下博客文章详细解释了如何使用嵌套工作流(如何获取直接调用 URI 和配置身份验证),并有一个很好的示例:https://blogs.msdn.microsoft.com/carlosag/2015/05/31/using-nested-azure-logic-apps-or-invoking-flows-from-another-logic-app/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-14
      • 1970-01-01
      • 2020-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-02
      • 1970-01-01
      相关资源
      最近更新 更多