尝试了一个简单的逻辑应用程序,我可以从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')"
}
]
}
感谢您的帮助。
问候
答案 0 :(得分: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/