在 Azure Data Factory 或 Synapse Analytics 中,利用複製活動來保留中繼資料和 ACL。

適用於: Azure Data Factory Azure Synapse Analytics

提示

Data Factory in Microsoft Fabric 是下一代的 Azure Data Factory,擁有更簡單的架構、內建 AI 及新功能。 如果你是資料整合新手,建議先從 Fabric Data Factory 開始。 現有的 ADF 工作負載可升級至 Fabric,以存取資料科學、即時分析與報告等新能力。

當您使用 Azure Data Factory 或 Synapse Analytics 管線複製活動,將資料從來源複製到接收時,在下列情境中,您也可以一併保留中繼資料和 ACL。

保留湖泊移轉的中繼資料

當你將資料從一個資料湖遷移到另一個時,包括Amazon S3Azure BlobAzure Data Lake Storage Gen2 以及 Azure 檔案儲存體,你可以選擇保留檔案元資料和資料。

複製活動 支援在資料複製過程中保留以下屬性:

  • 所有客戶指定的中繼資料
  • 以及下列五個資料存放區內建系統屬性contentTypecontentLanguage (Amazon S3 除外)、contentEncodingcontentDispositioncacheControl

處理元資料差異: Amazon S3 和 Azure 儲存體 允許在客戶指定的元資料鍵中使用不同字元組。 當您選擇使用複製活動保留中繼資料時,服務會自動以 '_' 取代無效的字元。

當你將檔案以原樣從 Amazon S3/Azure Data Lake Storage Gen2/Azure Blob 儲存/Azure 檔案儲存體 複製到 Azure Data Lake Storage Gen2/Azure Blob 儲存/Azure 檔案儲存體,並使用二進位格式時,你可以在 Copy Activity> 分頁中找到 Preserve 選項,或者在複製資料工具裡的 Settings 頁面中找到。

複製活動保留元資料

以下是複製活動 JSON 設定的範例 (請參閱 preserve):

"activities":[
    {
        "name": "CopyAndPreserveMetadata",
        "type": "Copy",
        "typeProperties": {
            "source": {
                "type": "BinarySource",
                "storeSettings": {
                    "type": "AmazonS3ReadSettings",
                    "recursive": true
                }
            },
            "sink": {
                "type": "BinarySink",
                "storeSettings": {
                    "type": "AzureBlobFSWriteSettings"
                }
            },
            "preserve": [
                "Attributes"
            ]
        },
        "inputs": [
            {
                "referenceName": "<Binary dataset Amazon S3/Azure Blob/ADLS Gen2 source>",
                "type": "DatasetReference"
            }
        ],
        "outputs": [
            {
                "referenceName": "<Binary dataset for Azure Blob/ADLS Gen2 sink>",
                "type": "DatasetReference"
            }
        ]
    }
]

保留從 Data Lake Storage Gen1/Gen2 到 Gen2 的存取控制清單 (ACL)

當您從 Azure Data Lake Storage Gen1 升級到 Gen2 或在 ADLS Gen2 間複製資料時,您可以選擇保留 POSIX 存取控制清單(ACL)以及資料檔案。 欲了解更多存取控制資訊,請參閱Azure Data Lake Storage Gen1中的存取控制及Azure Data Lake Storage Gen2中的存取控制。

複製活動 支援在資料複製時保留以下類型的 ACL。 您可以選取一或多個類型:

  • ACL:複製並保留檔案和目錄的 POSIX 存取控制清單。 其會將完整的現有 ACL 從來源複製到匯入端。
  • 擁有者:複製並保留檔案和目錄的擁有使用者。 需要具有接收 Data Lake Storage Gen2 的超級使用者存取權。
  • 群組:複製並保留檔案和目錄的擁有群組。 需要具有接收 Data Lake Storage Gen2 的超級使用者存取權,或擁有使用者存取權 (若擁有使用者也是目標群組成員)。

如果您指定從資料夾複製,recursive 若設為 true,則服務會複寫該指定資料夾的 ACL 及其下的檔案和目錄。 如果您指定從單一檔案複製,則會複製該檔案上的 ACL。

注意

當您使用複製活動,將 ACL 從 Data Lake Storage Gen1/Gen2 保留到 Gen2 時,接收 Gen2 對應資料夾/檔案上的現有 ACL 將會遭到覆寫。

重要

當您選擇保留 ACL 時,請務必授與服務足夠高的權限,以對接收 Data Lake Storage Gen2 帳戶執行作業。 例如,使用帳戶金鑰驗證,或將 Storage Blob Data Owner 角色指派給服務主體或受控識別。

當您將來源設定為使用二進位格式或二進位複製選項的 Data Lake Storage Gen1/Gen2,並將接收設定為使用二進位格式或二進位複製選項的 Data Lake Storage Gen2 時,您可以在資料複製工具的設定頁面上,或在活動撰寫時的複製活動>索引標籤上,找到保留選項。

Data Lake Storage Gen1/Gen2 轉為 Gen2 保留 ACL

以下是複製活動 JSON 設定的範例 (請參閱 preserve):

"activities":[
    {
        "name": "CopyAndPreserveACLs",
        "type": "Copy",
        "typeProperties": {
            "source": {
                "type": "BinarySource",
                "storeSettings": {
                    "type": "AzureDataLakeStoreReadSettings",
                    "recursive": true
                }
            },
            "sink": {
                "type": "BinarySink",
                "storeSettings": {
                    "type": "AzureBlobFSWriteSettings"
                }
            },
            "preserve": [
                "ACL",
                "Owner",
                "Group"
            ]
        },
        "inputs": [
            {
                "referenceName": "<Binary dataset name for Azure Data Lake Storage Gen1/Gen2 source>",
                "type": "DatasetReference"
            }
        ],
        "outputs": [
            {
                "referenceName": "<Binary dataset name for Azure Data Lake Storage Gen2 sink>",
                "type": "DatasetReference"
            }
        ]
    }
]

請參閱其他複製活動文章: