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

適用於:Azure Data Factory Azure Synapse Analytics

提示

試用 Microsoft Fabric 中的 Data Factory,這是適用於企業的全方位分析解決方案。 Microsoft Fabric 涵蓋從資料移動到資料科學、即時分析、商業智慧和報告的所有項目。 了解如何免費啟動新的試用版

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

保留資料湖移轉的中繼資料

當您將資料從某個資料湖移轉至另一個資料湖 (包括 Amazon S3Azure BlobAzure Data Lake Storage Gen2Azure 檔案儲存體) 時,您可以選擇保留檔案中繼資料以及資料。

複製活動支援在資料複製期間保留下列屬性:

  • 所有客戶指定的中繼資料
  • 以及下列五個資料存放區內建系統屬性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 metadata

以下是複製活動 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 的 ACL 保留到 Gen2

當您從 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 帳戶運作。 例如,使用帳戶金鑰驗證,或將儲存體 Blob 資料擁有者角色指派給服務主體或受控識別。

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

Data Lake Storage Gen1/Gen2 to Gen2 Preserve 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"
            }
        ]
    }
]

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