如何使用Azure数据工厂以下逻辑将文件从输入容器复制到输出容器。

huangapple go评论45阅读模式
英文:

How can I copy files from an input container to an output container using below logic with Azure data factory

问题

你可以如何将文件从 Azure Blob 存储的输入容器复制到输出容器,并根据文件大小将它们分类到三个不同的文件夹中:小于1KB的文件放入1KB文件夹,大小介于1KB到2KB之间的文件放入2KB文件夹,而大于2KB的文件放入大于2KB_More文件夹?

英文:

How can I copy files from an input container to an output container in Azure blob storage, and sort them into three different folders based on their file size, with files less than 1KB going to the 1KB folder, files between 1KB to 2KB going to the 2KB folder, and files larger than 2KB going to the more than 2KB_More folder?

Any one can help on this

答案1

得分: 0

Sure, here's the translation of the provided content:

请使用以下逻辑流程:

  1. 使用获取元数据活动获取输入容器内的子项目列表
  2. 使用ForEach活动以子项目列表为输入
  3. 在ForEach内,使用获取元数据活动获取文件大小
  4. 使用设置变量活动基于文件大小设置目标路径
  5. 使用带有动态接收器的复制活动
    动态示例:https://stackoverflow.com/questions/71042704/azure-data-factory-dynamic-content-filename-syntax
英文:

Please use the below logical flow :

  1. use get meta data activity to get child items list within the input container
  2. use for each activity with child items list as input
  3. within for each, use get meta data activity to get file size
  4. use set variable activity to set the destination path based on file size
  5. use copy activity with dynamic sink
    sample for dynamic : https://stackoverflow.com/questions/71042704/azure-data-factory-dynamic-content-filename-syntax

答案2

得分: 0

以下是您要翻译的内容:

在补充**@Nandan**的回答时,上述流程的第四步可以按以下方式完成。

从第二个获取元数据活动中获取文件大小后,首先使用以下表达式将字节转换为KB。

@string(div(activity('Get Metadata2').output.size,1024))

如何使用Azure数据工厂以下逻辑将文件从输入容器复制到输出容器。

然后在另一个变量中使用if表达式设置文件夹名称,如下所示。

@if(equals(int(variables('size')),0),'1KB',if(equals(int(variables('size')),1),'2KB','2KB_more'))

如何使用Azure数据工厂以下逻辑将文件从输入容器复制到输出容器。

将此名称用于接收数据集的文件夹名称。
我的结果:

如何使用Azure数据工厂以下逻辑将文件从输入容器复制到输出容器。

注意: 如果要复制不同类型的文件,最好使用二进制数据集。

英文:

Adding to @Nandan's answer, The 4th step in the above process can be done like below.

After getting file size from second Get meta data activity, first convert the bytes to KB with the below expression.

@string(div(activity('Get Metadata2').output.size,1024))

如何使用Azure数据工厂以下逻辑将文件从输入容器复制到输出容器。

Then use if expression in another variable set the folder names like below.

@if(equals(int(variables('size')),0),'1KB',if(equals(int(variables('size')),1),'2KB','2KB_more'))

如何使用Azure数据工厂以下逻辑将文件从输入容器复制到输出容器。

Use this name in the sink dataset foldername.
My Result:

如何使用Azure数据工厂以下逻辑将文件从输入容器复制到输出容器。

NOTE: If you are copying different types of files, it's better to use a binary datasets for this.

huangapple
  • 本文由 发表于 2023年5月10日 17:13:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76216719.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定