将存储数据从一个 Azure 帐户复制到另一个 Azure 帐户并组织到日期文件夹中

问题描述 投票:0回答:1

azcopy 复制 ' https://mysourceaccount.blob.core.windows.net/mycontainer' ' https://mydestinationaccount.blob.core.windows.net/mycontainer' --递归

上述操作会将所有内容从一个存储帐户复制到另一个存储帐户。我的要求是,应根据源容器中文件的上次修改日期在目标文件夹中组织数据。源容器是一个包含大量文件的大目录。

假设源文件中的文件是这样的

https://mysourceaccount.blob.core.windows.net/mycontainer/file1 最后修改日期为 2023 年 12 月 13 日

https://mysourceaccount.blob.core.windows.net/mycontainer/file2 最后修改日期为 2023 年 12 月 14 日

https://mysourceaccount.blob.core.windows.net/mycontainer/file3 最后修改日期为 2023 年 12 月 15 日

目标目录应如下所示进行复制,这将涉及根据源上次修改日期创建日期路径。

https://mydestinationaccount.blob.core.windows.net/mycontainer/2023/12/13/file1

https://mydestinationaccount.blob.core.windows.net/mycontainer/2023/12/15/file2

https://mydestinationaccount.blob.core.windows.net/mycontainer/2023/12/15/file3

azure azure-functions azure-data-factory azure-blob-storage azcopy
1个回答
0
投票

将存储数据从一个 Azure 帐户复制到另一个 Azure 帐户并组织到日期文件夹中。您需要使用获取元数据活动。请按照以下步骤操作:

  1. 首先为 Blob 存储创建数据集以在管道中使用。
  • 第一个数据集是从源数据集中获取文件。 enter image description here
  • 第二个数据集是获取特定文件的最后修改日期。创建文件名参数并将其添加到数据集连接中。 enter image description here enter image description here
  • 第三个数据集是根据目标容器中的最后修改日期创建文件夹。创建文件名、文件夹路径参数并将其添加到数据集连接中。 enter image description here enter image description here
  1. 现在创建一个管道并采取“获取元数据”活动从源容器获取文件列表,在此处添加我们创建的第一个数据集和
    Field list
    作为子项目 enter image description here
  2. 现在获取 Foreach 活动,并使用表达式
    @activity('Get Metadata1').output.childItems
    将获取元数据活动的结果传递给 Foreach 活动。 enter image description here
  3. 在此 Foreach 活动下,采取另一个获取元数据活动来获取文件的 lastmodified 日期。这里添加我们创建的第二个数据集,并将数据集参数添加为
    @item().name
    Field list
    最后修改 enter image description here
  4. 现在进行复制活动,将数据从源复制到接收器,并根据上次修改日期组织文件夹。这里添加我们在源中创建的第二个数据集,数据集参数为
    @item().name
    ,以及我们在接收器中创建的第三个数据集,文件名的数据集参数为
    @item().name
    ,文件夹路径为
    @formatDateTime(activity('Get Metadata2').output.lastModified,'yyyy/MM/dd')
    --来源enter image description here--水槽: enter image description here

输出:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.