使用 Azure Data Factory 將資料載入 Azure SQL 資料倉儲中Load data into Azure SQL Data Warehouse by using Azure Data Factory

Azure SQL 資料倉儲是一種雲端式的相應放大資料庫,可處理巨量關聯式與非關聯式資料。Azure SQL Data Warehouse is a cloud-based, scale-out database that's capable of processing massive volumes of data, both relational and non-relational. SQL 資料倉儲是以巨量平行處理 (MPP) 架構為基礎,最適用於企業資料倉儲工作負載。SQL Data Warehouse is built on the massively parallel processing (MPP) architecture that's optimized for enterprise data warehouse workloads. 它透過單獨調整儲存體和計算的彈性,來提供雲端彈性。It offers cloud elasticity with the flexibility to scale storage and compute independently.

現在,當您使用 Azure Data Factory 時,開始使用 Azure SQL 資料倉儲會比以往更為簡單。Getting started with Azure SQL Data Warehouse is now easier than ever when you use Azure Data Factory. Azure Data Factory 是完全受控的雲端式資料整合服務。Azure Data Factory is a fully managed cloud-based data integration service. 您可以使用此服務,在建置分析解決方案時於 SQL 資料倉儲中填入現有系統的資料並節省時間。You can use the service to populate a SQL Data Warehouse with data from your existing system and save time when building your analytics solutions.

Azure Data Factory 可針對將資料載入 Azure SQL 資料倉儲的作業提供下列優勢:Azure Data Factory offers the following benefits for loading data into Azure SQL Data Warehouse:

  • 容易設定:不需要編寫指令碼的直覺式 5 步驟精靈。Easy to set up: An intuitive 5-step wizard with no scripting required.
  • 豐富的資料存儲支援:對豐富的本地資料存儲和基於雲的資料存儲的內置支援。Rich data store support: Built-in support for a rich set of on-premises and cloud-based data stores. 如需詳細清單,請參閱支援的資料存放區的資料表。For a detailed list, see the table of Supported data stores.
  • 安全且符合規範:資料會透過 HTTPS 或 ExpressRoute 來傳送。Secure and compliant: Data is transferred over HTTPS or ExpressRoute. 具有全域服務,可確保資料絕不會離開地理界限。The global service presence ensures that your data never leaves the geographical boundary.
  • PolyBase 的無與倫比使用效能:Polybase 是將資料移至 Azure SQL 資料倉儲的最有效方式。Unparalleled performance by using PolyBase: Polybase is the most efficient way to move data into Azure SQL Data Warehouse. 使用暫存 Blob 功能來讓您能夠從所有類型的資料存放區 (包括 Azure Blob 儲存體和 Data Lake Store) 高速載入資料。Use the staging blob feature to achieve high load speeds from all types of data stores, including Azure Blob storage and Data Lake Store. (預設情況下,Polybase 支援 Azure Blob 存儲和 Azure 資料湖存儲。有關詳細資訊,請參閱複製活動性能(Polybase supports Azure Blob storage and Azure Data Lake Store by default.) For details, see Copy activity performance.

本文將示範如何使用 Data Factory 複製資料工具,將資料從 Azure SQL Database 載入 Azure SQL 資料倉儲中__。This article shows you how to use the Data Factory Copy Data tool to load data from Azure SQL Database into Azure SQL Data Warehouse. 您可以依照類似的步驟,從其他類型的資料存放區複製資料。You can follow similar steps to copy data from other types of data stores.


  • Azure 訂用帳戶:如果您沒有 Azure 訂用帳戶,請在開始前建立免費帳戶Azure subscription: If you don't have an Azure subscription, create a free account before you begin.
  • Azure SQL 資料倉儲:此資料倉儲會保存從 SQL 資料庫所複製過來的資料。Azure SQL Data Warehouse: The data warehouse holds the data that's copied over from the SQL database. 如果您沒有 Azure SQL 資料倉儲,請參閱建立 SQL 資料倉儲中的指示。If you don't have an Azure SQL Data Warehouse, see the instructions in Create a SQL Data Warehouse.
  • Azure SQL Database:本教學課程會從具有 Adventure Works LT 資料範例的 Azure SQL Database 複製資料。Azure SQL Database: This tutorial copies data from an Azure SQL database with Adventure Works LT sample data. 您可以遵循建立 Azure SQL 資料庫中的指示來建立 SQL 資料庫。You can create a SQL database by following the instructions in Create an Azure SQL database.
  • Azure 儲存體帳戶:大量複製作業會使用 Azure 儲存體作為「暫存」__ Blob。Azure storage account: Azure Storage is used as the staging blob in the bulk copy operation. 如果您沒有 Azure 儲存體帳戶,請參閱建立儲存體帳戶中的指示。If you don't have an Azure storage account, see the instructions in Create a storage account.

建立 Data FactoryCreate a data factory

  1. 在左側功能表上,選擇 "創建資源 > 資料 + 分析 > 資料工廠" :On the left menu, select Create a resource > Data + Analytics > Data Factory:

    在 [新增] 窗格中選取資料處理站

  2. 在 [新增資料處理站]**** 頁面中,為下圖所示的欄位提供值:In the New data factory page, provide values for the fields that are shown in the following image:


    • 名稱:輸入 Azure 資料處理站的全域唯一名稱。Name: Enter a globally unique name for your Azure data factory. 如果您收到「資料處理站名稱 "LoadSQLDWDemo" 無法使用」的錯誤,請為資料處理站輸入其他名稱。If you receive the error "Data factory name "LoadSQLDWDemo" is not available," enter a different name for the data factory. 例如,您可以使用_您的名稱_ADFTutorialDataFactoryFor example, you could use the name yournameADFTutorialDataFactory. 請嘗試再次建立資料處理站。Try creating the data factory again. 如需 Data Factory 成品的命名規則,請參閱 Data Factory 命名規則For the naming rules for Data Factory artifacts, see Data Factory naming rules.
    • 訂用帳戶:選取用來在其中建立資料處理站的 Azure 訂用帳戶。Subscription: Select your Azure subscription in which to create the data factory.
    • 資源群組:從下拉式清單中選取現有資源群組,或選取 [新建]**** 選項,然後輸入資源群組的名稱。Resource Group: Select an existing resource group from the drop-down list, or select the Create new option and enter the name of a resource group. 若要了解資源群組,請參閱 使用資源群組管理您的 Azure 資源To learn about resource groups, see Using resource groups to manage your Azure resources.
    • 版本:選取 [V2]****。Version: Select V2.
    • 位置:選取資料處理站的位置。Location: Select the location for the data factory. 只有受到支援的位置會顯示在下拉式清單中。Only supported locations are displayed in the drop-down list. 資料處理站所使用的資料存放區可位於其他位置和區域。The data stores that are used by data factory can be in other locations and regions. 這些資料存放區包含 Azure Data Lake Store、Azure 儲存體、Azure SQL Database 等等。These data stores include Azure Data Lake Store, Azure Storage, Azure SQL Database, and so on.
  3. 選取 [建立]****。Select Create.

  4. 建立完成後,請移至資料處理站。After creation is complete, go to your data factory. 您會看到如下圖所示的 [Data Factory]**** 首頁:You see the Data Factory home page as shown in the following image:

    Data Factory 首頁

    選取 [編寫與監視]**** 圖格,以在另一個索引標籤中啟動資料整合應用程式。Select the Author & Monitor tile to launch the Data Integration Application in a separate tab.

將資料載入 Azure SQL 資料倉儲Load data into Azure SQL Data Warehouse

  1. 在 [開始使用]**** 頁面中,選取 [複製資料]**** 圖格以啟動複製資料工具:In the Get started page, select the Copy Data tile to launch the Copy Data tool:


  2. 在 [屬性]**** 頁面中,對 [工作名稱]**** 欄位指定 [CopyFromSQLToSQLDW]****,然後選取 [下一步]****:In the Properties page, specify CopyFromSQLToSQLDW for the Task name field, and select Next:


  3. 在 [來源資料存放區]**** 頁面中,完成下列步驟:In the Source data store page, complete the following steps:

    a.a. 按一下 [+ 建立新連線]****:click + Create new connection:


    b.b. 從資源庫選取 [Azure SQL Database]****,然後選取 [繼續]****。Select Azure SQL Database from the gallery, and select Continue. 您可以在搜尋方塊中輸入 "SQL",以篩選連接器。You can type "SQL" in the search box to filter the connectors.

    選取 Azure SQL DB

    c.c. "新建連結服務" 頁中,從下拉清單中選擇伺服器名稱和資料庫名稱,並指定使用者名和密碼。In the New Linked Service page, select your server name and DB name from the dropdown list, and specify the username and password. 按一下 [測試連線]**** 以驗證設定,然後選取 [完成]****。Click Test connection to validate the settings, then select Finish.

    設定 Azure SQL DB

    d.d. 選取新建立的連結服務作為來源,然後按 [下一步]****。Select the newly created linked service as source, then click Next.


  4. 在 [選取要從中複製資料的資料表或使用自訂查詢]**** 頁面中,輸入 SalesLT 以篩選資料表。In the Select tables from which to copy the data or use a custom query page, enter SalesLT to filter the tables. 選擇 [(全選)]**** 方塊以讓所有資料表都用於複製,然後選取 [下一步]****:Choose the (Select all) box to use all of the tables for the copy, and then select Next:


  5. 在 [目的地資料存放區]**** 頁面中,完成下列步驟:In the Destination data store page, complete the following steps:

    a.a. 按一下 [+ 建立新連線]**** 以新增連線Click + Create new connection to add a connection


    b.b. 從資源庫選取 [Azure SQL 資料倉儲]****,然後選取 [下一步]****。Select Azure SQL Data Warehouse from the gallery, and select Next.

    選取 Azure SQL 資料倉儲

    c.c. "新建連結服務" 頁中,從下拉清單中選擇伺服器名稱和資料庫名稱,並指定使用者名和密碼。In the New Linked Service page, select your server name and DB name from the dropdown list, and specify the username and password. 按一下 [測試連線]**** 以驗證設定,然後選取 [完成]****。Click Test connection to validate the settings, then select Finish.

    設定 Azure SQL 資料倉儲

    d.d. 選取新建立的連結服務作為接收端,然後按 [下一步]****。Select the newly created linked service as sink, then click Next.


  6. 在 [資料表對應]**** 頁面上檢閱內容,然後選取 [下一步]****。In the Table mapping page, review the content, and select Next. 隨即會顯示智慧型資料表對應。An intelligent table mapping displays. 來源資料表會根據資料表名稱來對應至目的地資料表。The source tables are mapped to the destination tables based on the table names. 如果有某個來源資料表未存在於目的地中,Azure Data Factory 預設會建立具有相同名稱的目的地資料表。If a source table doesn't exist in the destination, Azure Data Factory creates a destination table with the same name by default. 您也可以將來源資料表對應至現有的目的地資料表。You can also map a source table to an existing destination table.


    當來源為 SQL Server 或 Azure SQL Database 時,系統便會自動為 SQL 資料倉儲接收建立資料表。Automatic table creation for the SQL Data Warehouse sink applies when SQL Server or Azure SQL Database is the source. 如果您從其他來源資料存放區複製資料,就必須在執行資料複製之前,先在接收 Azure SQL 資料倉儲中預先建立結構描述。If you copy data from another source data store, you need to pre-create the schema in the sink Azure SQL Data Warehouse before executing the data copy.


  7. 在 [結構描述對應]**** 頁面上檢閱內容,然後選取 [下一步]****。In the Schema mapping page, review the content, and select Next. 系統會根據資料行名稱來進行智慧型資料表對應。The intelligent table mapping is based on the column name. 如果您讓 Data Factory 自動建立資料表,而來源和目的地存放區之間有不相容的問題時,系統便會轉換資料類型。If you let Data Factory automatically create the tables, data type conversion can occur when there are incompatibilities between the source and destination stores. 如果來源和目的地資料行之間有不支援的資料類型轉換,您就會在對應的資料表旁看到一則錯誤訊息。If there's an unsupported data type conversion between the source and destination column, you see an error message next to the corresponding table.


  8. 在 [設定]**** 頁面中,完成下列步驟:In the Settings page, complete the following steps:

    a.a. 在 [暫存設定]**** 區段中,按一下 [+ 新增]**** 以新增暫存儲存體。In Staging settings section, click + New to new a staging storage. 此儲存體可用來暫存資料,之後再使用 PolyBase 將資料載入到 SQL 資料倉儲。The storage is used for staging the data before it loads into SQL Data Warehouse by using PolyBase. 複製完成後,系統會自動清除 Azure 儲存體中的暫存資料。After the copy is complete, the interim data in Azure Storage is automatically cleaned up.


    b.b. 在 [新增連結服務]**** 頁面中,選取您的儲存體帳戶,然後選取 [完成]****。In the New Linked Service page, select your storage account, and select Finish.

    設定 Azure 儲存體

    c.c. 在 [進階設定]**** 區段中,取消選取 [使用類型預設值]**** 選項,然後選取 [下一步]****。In the Advanced settings section, deselect the Use type default option, then select Next.

    設定 PolyBase

  9. 在 [摘要]**** 頁面中檢閱設定,然後選取 [下一步]****:In the Summary page, review the settings, and select Next:


  10. 部署頁面上選取 [監視]**** 來監視管線 (工作):In the Deployment page, select Monitor to monitor the pipeline (task):


  11. 請注意,系統會自動選取左側的 [監視]**** 索引標籤。Notice that the Monitor tab on the left is automatically selected. "操作" 列包含用於查看活動運行詳細資訊和重新運行管道的連結:The Actions column includes links to view activity run details and to rerun the pipeline:


  12. 若要檢視與此管線執行相關聯的活動執行,請選取 [動作]**** 資料行中的 [檢視活動執行]**** 連結。To view activity runs that are associated with the pipeline run, select the View Activity Runs link in the Actions column. 若要切換回 [管線執行] 檢視,請選取頂端的 [管線]**** 連結。To switch back to the pipeline runs view, select the Pipelines link at the top. 選取 [重新整理]**** 可重新整理清單。Select Refresh to refresh the list.


  13. 若要監視每個複製活動的執行詳細資料,請選取活動監控檢視中 [動作]**** 底下的 [詳細資料]**** 連結。To monitor the execution details for each copy activity, select the Details link under Actions in the activity monitoring view. 您可以監視的詳細資料包括從來源複製到接收的資料量、資料輸送量、執行步驟與對應的持續期間,以及所使用的設定:You can monitor details like the volume of data copied from the source to the sink, data throughput, execution steps with corresponding duration, and used configurations:


後續步驟Next steps

前往下列文章,以了解 Azure SQL 資料倉儲支援:Advance to the following article to learn about Azure SQL Data Warehouse support: