简体   繁体   English

使用“添加或修改 blob 时(仅限属性)(V2)”时检索多个 blob

[英]Retrieving more than one blob when using "When a blob is added or modified (properties only) (V2)"

I've an automated task elsewhere that creates 2 files within an Azure Blob Storage container:我在其他地方有一个自动任务,它在 Azure Blob 存储容器中创建 2 个文件:

存储在 Azure Blob 存储中的文件

Once this has been done, I then fire a Logic app which has uses the trigger "When a blob is added or modified (properties only) (V2)"完成此操作后,我将启动一个逻辑应用程序,该应用程序使用触发器“添加或修改 blob 时(仅限属性)(V2)”

在此处输入图像描述

As you can see I have number of blobs to return set to 2, and if we look at the setting I have "split-on" off:如您所见,我将要返回的 blob 数设置为 2,如果我们查看设置,我会关闭“拆分”:

在此处输入图像描述

However when logic app is triggered its only retrieving 1 file in the array at a time:但是,当逻辑应用程序被触发时,它一次只检索数组中的 1 个文件:

在此处输入图像描述

The rest of my logic app is setup to handle and array - as the end game is send an email with a list of attachments, but given how this is being triggered end up with 2 emails each one with a single attachment.我的逻辑应用程序的 rest 设置为处理和排列 - 因为结束游戏是发送带有附件列表的 email,但考虑到这是如何触发的,最终会收到 2 封电子邮件,每封电子邮件都有一个附件。

Is this the way this trigger should work?这是这个触发器应该工作的方式吗? or am I wrong somewhere?还是我哪里错了?

EDIT: Including the code for the trigger:编辑:包括触发器的代码: 在此处输入图像描述

The reason that you are facing this is due to the number of files that you are uploading.您面临这种情况的原因是您上传的文件数量。

To make this work one of the workarounds is that you can use recurrence trigger having an interval of 1 minute and use a filter array to get the list of blobs that got added for that minute.要使这项工作成为解决方法之一,您可以使用间隔为 1 分钟的重复触发器并使用过滤器数组来获取那一分钟添加的 blob 列表。

在此处输入图像描述

In the filter array, I am filtering it for that instance of a minute only.在过滤器数组中,我只过滤了一分钟的实例。 The syntax I'm using here for greater than or equal to operation on the last modified time is formatDateTime(utcNow(), 'yyyy-MM-ddTHH:mm:00Z') .我在此处用于greater than or equal to上次修改时间操作的语法是formatDateTime(utcNow(), 'yyyy-MM-ddTHH:mm:00Z')

Then I'm using a variable to store the resultant list in an array by having an append to array variable connector for each item.然后我使用一个变量将结果列表存储在一个数组中,方法是为每个项目设置一个 append 到数组变量连接器。

在此处输入图像描述

Then I'm using a Condition Connector to check if I'm receiving anything in the array and then send the list of blobs using the outlook connector.然后我使用条件连接器检查我是否收到数组中的任何内容,然后使用 outlook 连接器发送list of blobs If there is no content or there are no blobs that got added in that minute the goes into false section, else true.如果在那一分钟内没有内容或没有添加任何 blob,则进入错误部分,否则为真。

The condition that I'm checking here is the length of the listOfBlobs array:- length(variables('listOfBlobs')) is not equal to 0我在这里检查的条件是listOfBlobs数组的长度:- length(variables('listOfBlobs')) is not equal to 0

在此处输入图像描述

So here is what I receive when the length of listOfArray variable is 0, It won't trigger any mail as there are no blobs uploaded and goes into false section.所以这是我在listOfArray变量的长度为 0 时收到的内容,它不会触发任何邮件,因为没有上传任何 blob 并进入错误部分。

在此处输入图像描述

here is what I receive when the length of listOfArray variable is not 0, It triggers mail with the blob content in it.这是我在listOfArray变量的长度不为 0 时收到的内容,它会触发其中包含 blob 内容的邮件。

在此处输入图像描述

Here is what I have uploaded to my storage account:-这是我上传到我的存储帐户的内容:-在此处输入图像描述

Here is the mail that triggered in my inbox.这是在我的收件箱中触发的邮件。在此处输入图像描述

[{"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"}]

Here is the code view of my logic app这是我的逻辑应用程序的代码视图

{
    "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": "v-swethaka@microsoft.com"
                            },
                            "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"
                }
            }
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 blob 从一个容器复制到另一个容器时出错,最终内容在 C# 中为 0 字节 - Error when copying a blob from one container to another, the content final is 0 bytes in C# 使用 Java sdk 在 azure blob 存储中上传文件时强制执行 TLS 1.2 - Enforce TLS 1.2 when uploading files in azure blob storage using Java sdk 当我尝试使用 DataFactory 将数据从 Azure Blob 复制到 SQL Datawarehouse 时出现异常 - Getting exception when i try to copy data from Azure Blob to SQL Datawarehouse using DataFactory 数据工厂 - 仅当从 Blob 触发时无法连接到 SQL 数据库 - Data Factory - Cannot connect to SQL Database only when triggered from Blob Azure Blob 触发器 Function 使用 NLog 更新文件时仅触发一次 - Azure Blob Trigger Function triggering only once when file is updated with NLog 在 Azure blob 存储上托管时如何使 Angular 路由工作 - How to get Angular routing working when hosting on Azure blob storage 指定的 blob 不存在 - 设置时 http header - The Specified blob does not exist - when setting http header 在 Azure Blob 存储上上传大 Blob 时延长令牌过期时间 - Extend token expiration when uploading large blobs on Azure Blob Storage 覆盖 Blob 存储上的 Blob - 获取“只读”异常 - Overwrite a blob on Blob Storage - getting "read only" exception 将新文件从 sharepoint 检索到 blob - Retrieving new files from sharepoint to blob
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM