1

尝试了一个简单的逻辑应用程序,我可以在其中从 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')"
            }
        ]
    }

感谢您的任何帮助。

问候

4

1 回答 1

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 /使用-嵌套-azure-logic-apps-或-invoking-flows-from-another-logic-app/

于 2016-02-11T01:21:53.573 回答