gpt4 book ai didi

azure - 使用 "When a blob is added or modified (properties only) (V2)"时检索多个 blob

转载 作者:行者123 更新时间:2023-12-03 02:16:31 25 4
gpt4 key购买 nike

我在其他地方有一个自动化任务,该任务在 Azure Blob 存储容器中创建 2 个文件:

Files stored in Azure Blob Storage

完成此操作后,我将启动一个逻辑应用程序,该应用程序使用触发器“添加或修改 blob 时(仅属性)(V2)”

enter image description here

正如你所看到的,我要返回的 blob 数量设置为 2,如果我们查看设置,我关闭了“split-on”:

enter image description here

但是,当触发逻辑应用时,它一次仅检索数组中的 1 个文件:

enter image description here

我的逻辑应用程序的其余部分设置为处理和数组 - 因为最终游戏是发送一封带有附件列表的电子邮件,但考虑到这是如何触发的,最终会收到 2 封电子邮件,每封电子邮件都有一个附件。

这是这个触发器应该工作的方式吗?还是我哪里错了?

编辑:包括触发器的代码: enter image description here

最佳答案

您遇到此问题的原因是您上传的文件数量过多。

要实现此目的,解决方法之一是您可以使用间隔为 1 分钟的重复触发器,并使用过滤器数组来获取该分钟添加的 Blob 列表。

enter image description here

在过滤器数组中,我仅针对该分钟的实例进行过滤。我在这里对上次修改时间使用大于或等于操作的语法是formatDateTime(utcNow(), 'yyyy-MM -ddTHH:mm:00Z')

然后,我使用变量将结果列表存储在数组中,方法是将每个项目附加到数组变量连接器。

enter image description here

然后,我使用条件连接器检查是否收到数组中的任何内容,然后使用 Outlook 连接器发送 blob 列表。如果在那一分钟内没有内容或没有添加任何 blob,则进入 false 部分,否则为 true。

我在这里检查的条件是 listOfBlobs 数组的长度:-length(variables('listOfBlobs')) 不等于 0

enter image description here

这是当 listOfArray 变量的长度为 0 时我收到的内容,它不会触发任何邮件,因为没有上传 Blob 并进入 false 部分。

enter image description here

这是当 listOfArray 变量的长度不为 0 时我收到的内容,它会触发包含 blob 内容的邮件。

enter image description here

这是我上传到我的存储帐户的内容:- enter image description here

这是在我的收件箱中触发的邮件。 enter image description here

[{"pysamp.txt":"{\"Id\":\"<ID>",\"Name\":\"pysamp.txt\",\"DisplayName\":\"pysamp.txt\",\"Path\":\"/container2408/pysamp.txt\",\"LastModified\":\"2022-02-14T05:26:08Z\",\"Size\":58,\"MediaType\":\"text/plain\",\"IsFolder\":false,\"ETag\":\"\\\"0x8D9EF7A8133FFF9\\\"\",\"FileLocator\":\"JTJmY29udGFpbmVyMjQwOCUyZnB5c2FtcC50eHQ=\",\"LastModifiedBy\":null}\\n"},
{"aaa.txt":"{\"Id\":\"<ID>\",\"Name\":\"aaa.txt\",\"DisplayName\":\"aaa.txt\",\"Path\":\"/container2408/aaa.txt\",\"LastModified\":\"2022-02-14T05:26:08Z\",\"Size\":8686,\"MediaType\":\"text/plain\",\"IsFolder\":false,\"ETag\":\"\\\"0x8D9EF7A813F6FFB\\\"\",\"FileLocator\":\"JTJmY29udGFpbmVyMjQwOCUyZmFhYS50eHQ=\",\"LastModifiedBy\":null}\\n"}]

这是我的逻辑应用的代码 View

{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "@variables('listOfBlobs')",
"runAfter": {
"For_each_2": [
"Succeeded"
]
},
"type": "Compose"
},
"Condition": {
"actions": {
"Send_an_email_(V2)": {
"inputs": {
"body": {
"Body": "<p>@{outputs('Compose')}</p>",
"Subject": "Sample",
"To": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="53257e202436273b323832133e3a30213c203c35277d303c3e" rel="noreferrer noopener nofollow">[email protected]</a>"
},
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
},
"runAfter": {},
"type": "ApiConnection"
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@length(variables('listOfBlobs'))",
0
]
}
}
]
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "If"
},
"Filter_array": {
"inputs": {
"from": "@body('Lists_blobs_(V2)')?['value']",
"where": "@greaterOrEquals(item()?['LastModified'], formatDateTime(utcNow(), 'yyyy-MM-ddTHH:mm:00Z'))"
},
"runAfter": {
"Lists_blobs_(V2)": [
"Succeeded"
]
},
"type": "Query"
},
"For_each_2": {
"actions": {
"Append_to_array_variable": {
"inputs": {
"name": "listOfBlobs",
"value": {
"@items('For_each_2')?['DisplayName']": "@{items('For_each_2')}\\n"
}
},
"runAfter": {},
"type": "AppendToArrayVariable"
}
},
"foreach": "@body('Filter_array')",
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "Foreach"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "listOfBlobs",
"type": "array"
}
]
},
"runAfter": {
"Filter_array": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Lists_blobs_(V2)": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "get",
"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/foldersV2/@{encodeURIComponent(encodeURIComponent('JTJmY29udGFpbmVyMjQwOA=='))}",
"queries": {
"nextPageMarker": ""
}
},
"metadata": {
"JTJmY29udGFpbmVyMjQwOA==": "/container2408"
},
"runAfter": {},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"recurrence": {
"frequency": "Minute",
"interval": 1
},
"type": "recurrence"
}
}
},
"parameters": {
"$connections": {
"value": {
"azureblob": {
"connectionId": "/subscriptions/<YOUR_SUBSCRIPTION>/resourceGroups/<YOUR_RESOURCEGROUP>/providers/Microsoft.Web/connections/azureblob",
"connectionName": "azureblob",
"id": "/subscriptions/<YOUR_SUBSCRIPTION>/providers/Microsoft.Web/locations/northcentralus/managedApis/azureblob"
},
"office365": {
"connectionId": "/subscriptions/<YOUR_SUBSCRIPTION>/resourceGroups/<YOUR_RESOURCEGROUP>/providers/Microsoft.Web/connections/office365",
"connectionName": "office365",
"id": "/subscriptions/<YOUR_SUBSCRIPTION>/providers/Microsoft.Web/locations/northcentralus/managedApis/office365"
}
}
}
}
}

关于azure - 使用 "When a blob is added or modified (properties only) (V2)"时检索多个 blob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71070500/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com