通过 Azure 数据工厂复制多个文件夹Copy multiple folders with Azure Data Factory
Azure 数据工厂
Azure Synapse Analytics
本文介绍了一个解决方案模板。你可以通过该模板使用多个复制活动在基于文件的存储(每个复制活动都会在其中复制单个容器或文件夹)之间复制容器或文件夹。This article describes a solution template that you can use multiple copy activities to copy containers or folders between file-based stores, where each copy activity is supposed to copy single container or folder.
备注
若要复制单个容器中的文件,使用复制数据工具通过单个复制活动创建管道的做法会更有效。If you want to copy files from a single container, it's more efficient to use the Copy Data Tool to create a pipeline with a single copy activity. 本文中的模板超出了你对该简单方案的需求。The template in this article is more than you need for that simple scenario.
关于此解决方案模板About this solution template
此模板会枚举源存储库中给定父文件夹中的文件夹。This template enumerates the folders from a given parent folder on your source storage store. 然后,它会将每个文件夹复制到目标存储。It then copies each of the folders to the destination store.
该模板包含三个活动:The template contains three activities:
- GetMetadata 会扫描源存储库,并从给定的父文件夹中获取子文件夹列表。GetMetadata scans your source storage store and gets the subfolder list from a given parent folder.
- ForEach 会获取 GetMetadata 活动提供的子文件夹列表,然后循环访问该列表并将每个文件夹传递到 Copy 活动。ForEach gets the subfolder list from the GetMetadata activity and then iterates over the list and passes each folder to the Copy activity.
- Copy 会将源存储中的每个文件夹复制到目标存储。Copy copies each folder from the source storage store to the destination store.
模板定义以下参数:The template defines the following parameters:
- SourceFileFolder 是以下数据源存储的父文件夹路径的一部分:SourceFileFolder/SourceFileDirectory,你可以在其中获取子文件夹的列表。SourceFileFolder is part the parent folder path of your data source store: SourceFileFolder/SourceFileDirectory, where you can get a list of the subfolders.
- SourceFileDirectory 是以下数据源存储的父文件夹路径的一部分:SourceFileFolder/SourceFileDirectory,你可以在其中获取子文件夹的列表。SourceFileDirectory is part the parent folder path of your data source store: SourceFileFolder/SourceFileDirectory, where you can get a list of the subfolders.
- DestinationFileFolder 是以下父文件夹路径的一部分:DestinationFileFolder/DestinationFileDirectory,可以在其中将文件复制到目标存储。DestinationFileFolder is part the parent folder path: DestinationFileFolder/DestinationFileDirectory where the files will be copied to your destination store.
- DestinationFileDirectory 是父文件夹路径的一部分:DestinationFileFolder/DestinationFileDirectory,可以在其中将文件复制到目标存储。DestinationFileDirectory is part the parent folder path: DestinationFileFolder/DestinationFileDirectory where the files will be copied to your destination store.
如果要在存储之间复制根文件夹下的多个容器,则可以以“/”形式输入所有四个参数。If you want to copy multiple containers under root folders between storage stores, you can input all four parameters as /. 这样,你将在存储之间复制所有内容。By doing so, you will replicate everything between storage stores.
如何使用此解决方案模板How to use this solution template
转到“在文件存储之间复制多个文件容器”模板。Go to the Copy multiple files containers between File Stores template. 创建与源存储的 新 连接。Create a New connection to your source storage store. 源存储是你要从多个容器复制文件的位置。The source storage store is where you want to copy files from multiple containers from.
创建与目标存储的 新 连接。Create a New connection to your destination storage store.
选择“使用此模板” 。Select Use this template.
你将看到管道,如以下示例所示:You'll see the pipeline, as in the following example:
选择“调试”,输入“参数”,然后选择“完成”。Select Debug, enter the Parameters, and then select Finish.
查看结果。Review the result.