|
| 1 | +--- |
| 2 | +title: Capture changed data with a change data capture resource |
| 3 | +description: This tutorial provides step-by-step instructions on how to capture changed data from ADLS Gen2 to SQL DB using a Change data capture resource. |
| 4 | +author: n0elleli |
| 5 | +ms.author: noelleli |
| 6 | +ms.reviewer: |
| 7 | +ms.service: data-factory |
| 8 | +ms.subservice: |
| 9 | +ms.topic: conceptual |
| 10 | +ms.custom: seo-lt-2019 |
| 11 | +ms.date: 01/20/2023 |
| 12 | +--- |
| 13 | + |
| 14 | +# How to capture changed data from ADLS Gen2 to SQL DB using a Change data capture resource |
| 15 | +[!INCLUDE[appliesto-adf-asa-md]] |
| 16 | + |
| 17 | +In this tutorial, you will use the Azure Data Factory user interface (UI) to create a new Change data capture resource that picks up changed data from an Azure Data Lake Storage (ADLS) Gen2 source to a SQL Database. The configuration pattern in this tutorial can be modified and expanded upon. |
| 18 | + |
| 19 | +In this tutorial, you follow these steps: |
| 20 | +* Create a change data capture resource. |
| 21 | +* Monitor change data capture activity. |
| 22 | + |
| 23 | +## Pre-requisites |
| 24 | + |
| 25 | +* **Azure subscription.** If you don't have an Azure subscription, create a free Azure account before you begin. |
| 26 | +* **Azure storage account.** You use ADLS storage as a source data store. If you don't have a storage account, see Create an Azure storage account for steps to create one. |
| 27 | +* **Azure SQL Database.** You will use Azure SQL DB as a target data store. If you don’t have a SQL DB, please create one in the Azure portal first before continuing the tutorial. |
| 28 | + |
| 29 | + |
| 30 | +## Create a change data capture artifact |
| 31 | + |
| 32 | +1. Navigate to the **Author** blade in your data factory. You will see a new top-level artifact under **Pipelines** called **Change data capture (preview)**. |
| 33 | + |
| 34 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-2.png" alt-text="Screenshot of new top level artifact shown under Factory resources panel."::: |
| 35 | + |
| 36 | +2. To create a new **Change data capture**, hover over **Change data capture (preview)** until you see 3 dots appear. Click on the **Change data capture actions**. |
| 37 | + |
| 38 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-3.png" alt-text="Screenshot of Change data capture (preview) Actions after hovering on the new top-level artifact."::: |
| 39 | + |
| 40 | +3. Select **New change data capture (preview)**. This will open a flyout to begin the guided process. |
| 41 | + |
| 42 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-4.png" alt-text="Screenshot of a list of change data capture actions."::: |
| 43 | + |
| 44 | +4. You will then be prompted to name your CDC resource. By default, the name will be set to “adfcdc” and continue to increment up by 1. You can replace this default name with your own. |
| 45 | + |
| 46 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-5.png" alt-text="Screenshot of the text box to update the name of the resource."::: |
| 47 | + |
| 48 | +5. Use the drop-down selection list to choose your data source. For this tutorial, we will use **DelimitedText**. |
| 49 | + |
| 50 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-6.png" alt-text="Screenshot of the guided process flyout with source options in a drop-down selection menu."::: |
| 51 | + |
| 52 | +6. You will then be prompted to select a linked service. Create a new linked service or select an existing one. |
| 53 | + |
| 54 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-7.png" alt-text="Screenshot of the selection box to choose or create a new linked service."::: |
| 55 | + |
| 56 | +7. Use the **Browse** button to select your source data folder. |
| 57 | + |
| 58 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-8.png" alt-text="Screenshot of a folder icon to browse for a folder path."::: |
| 59 | + |
| 60 | +8. Once you’ve selected a folder path, click **Continue** to set your data target. |
| 61 | + |
| 62 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-9.png" alt-text="Screenshot of the continue button in the guided process to proceed to select data targets."::: |
| 63 | + |
| 64 | +> [!NOTE] |
| 65 | +> You can choose to add multiple source folders with the **+** button. The other sources must also use the same linked service that you’ve already selected. |
| 66 | +
|
| 67 | +9. Then, select a **Target type** using the drop-down selection. For this tutorial, we will select **Azure SQL Database**. |
| 68 | + |
| 69 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-10.png" alt-text="Screenshot of a drop-down selection menu of all data target types."::: |
| 70 | + |
| 71 | +10. You will then be prompted to select a linked service. Create a new linked service or select an existing one. |
| 72 | + |
| 73 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-11.png" alt-text="Screenshot of the selection box to choose or create a new linked service to your data target."::: |
| 74 | + |
| 75 | +11. Create new **Target table(s)** or select an existing **Target table(s)**. Use the checkbox to make your selection(s). The **Preview** button will allow you to view your table data. |
| 76 | + |
| 77 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-12.png" alt-text="Screenshot of the create new tables button and the selection boxes to choose tables for your target."::: |
| 78 | + |
| 79 | +12. Click **Continue** when you have finalized your selection(s). |
| 80 | + |
| 81 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-13.png" alt-text="Screenshot of the continue button in the guided process to proceed to the next step."::: |
| 82 | + |
| 83 | +> [!NOTE] |
| 84 | +> You can choose multiple target tables from your SQL DB. Use the check boxes to select all targets. |
| 85 | +
|
| 86 | +13. You will automatically land in a new change data capture tab, where you can configure your new resource. |
| 87 | + |
| 88 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-14.png" alt-text="Screenshot of the change data capture studio."::: |
| 89 | + |
| 90 | +14. A new mapping will automatically be created for you. You can update the **Source** and **Target** selections for your mapping by using the drop-down selection lists. |
| 91 | + |
| 92 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-15.png" alt-text="Screenshot of the source to target mapping in the change data capture studio."::: |
| 93 | + |
| 94 | +15. Once you’ve selected your tables, you should see that there are columns mapped. Select the **Column mappings** button to view the column mappings. |
| 95 | + |
| 96 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-16.png" alt-text="Screenshot of the mapping icon to view column mappings."::: |
| 97 | + |
| 98 | +16. Here you can view your column mappings. Use the drop-down lists to edit your column mappings for **Mapping method**, **Source column**, and **Target** column. |
| 99 | + |
| 100 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-17.png" alt-text="Screenshot of the column mappings."::: |
| 101 | + |
| 102 | + You can add additional column mappings using the **New mapping** button. Use the drop-down lists to select the **Mapping method**, **Source column**, and **Target** column. |
| 103 | + |
| 104 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-18.png" alt-text="Screenshot of the Add new mapping icon to add new column mappings."::: |
| 105 | + |
| 106 | +17. When your mapping is complete, click the back arrow to return to the main canvas. |
| 107 | + |
| 108 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-19.png" alt-text="Screenshot of the arrow icon to return to the main change data capture canvas."::: |
| 109 | + |
| 110 | +> [!NOTE] |
| 111 | +> You can add additional source to target mappings in one CDC artifact. Use the edit button to select more data sources and targets. Then, click **New mapping** and use the drop-down lists to set a new source and target mapping. |
| 112 | +
|
| 113 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-20.png" alt-text="Screenshot of the edit button to add new sources."::: |
| 114 | + |
| 115 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-21.png" alt-text="Screenshot of the new mapping button to set a new source to target mapping."::: |
| 116 | + |
| 117 | +18. Once your mapping complete, set your frequency using the **Set Latency** button. |
| 118 | + |
| 119 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-22.png" alt-text="Screenshot of the set frequency button at the top of the canvas."::: |
| 120 | + |
| 121 | +19. Select the cadence of your change data capture and click **Apply** to make the changes. By default, it will be set to 15 minutes. |
| 122 | + |
| 123 | +For example, if you select 30 minutes, every 30 minutes, your change data capture will process your source data and pick up any changed data since the last processed time. |
| 124 | + |
| 125 | +:::image type="content" source="media/adf-cdc/change-data-capture-resource-23.png" alt-text="Screenshot of the set frequency selection menu."::: |
| 126 | + |
| 127 | +> [!NOTE] |
| 128 | +> The option to select Real-time to enable streaming data integration is coming soon. |
| 129 | +
|
| 130 | +20. Once everything has been finalized, publish your changes. |
| 131 | + |
| 132 | +:::image type="content" source="media/adf-cdc/change-data-capture-resource-24.png" alt-text="Screenshot of the publish button at the top of the canvas."::: |
| 133 | + |
| 134 | +> [!NOTE] |
| 135 | +> If you do not publish your changes, you will not be able to start your CDC resource. The start button will be grayed out. |
| 136 | +
|
| 137 | +21. Click **Start** to start running your **Change data capture**. |
| 138 | + |
| 139 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-25.png" alt-text="Screenshot of the start button at the top of the canvas."::: |
| 140 | + |
| 141 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-26.png" alt-text="Screenshot of an actively running change data capture resource."::: |
| 142 | + |
| 143 | + |
| 144 | +## Monitor your Change data capture |
| 145 | + |
| 146 | +1. To monitor your change data capture, navigate to the **Monitor** blade or click the monitoring icon from the CDC designer. |
| 147 | + |
| 148 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-27.png" alt-text="Screenshot of the monitoring blade."::: |
| 149 | + |
| 150 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-28.png" alt-text="Screenshot of the monitoring button at the top of the change data capture canvas."::: |
| 151 | + |
| 152 | +2. Select **Change data capture** to view your CDC resources. |
| 153 | + |
| 154 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-29.png" alt-text="Screenshot of the Change data capture monitoring section."::: |
| 155 | + |
| 156 | +3. Here you can see the **Source**, **Target**, **Status**, and **Last processed** time of your change data capture. |
| 157 | + |
| 158 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-30.png" alt-text="Screenshot of an overview of the change data capture monitoring page."::: |
| 159 | + |
| 160 | +4. Click the name of your CDC to see more details. You can see how many rows were read and written and other diagnostic information. |
| 161 | + |
| 162 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-31.png" alt-text="Screenshot of the detailed monitoring of a selected change data capture."::: |
| 163 | + |
| 164 | +> [!NOTE] |
| 165 | +> If you have multiple mappings set up in your Change data capture, each mapping will show as a different color. Click on the bar to see specific details for each mapping or use the Diagnostics at the bottom of the screen. |
| 166 | +
|
| 167 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-32.png" alt-text="Screenshot of the detailed monitoring page of a change data capture with multiple sources to target mappings."::: |
| 168 | + |
| 169 | + :::image type="content" source="media/adf-cdc/change-data-capture-resource-33.png" alt-text="Screenshot of a detailed breakdown of each mapping in the change data capture artifact."::: |
| 170 | + |
| 171 | + |
| 172 | +## Next steps |
| 173 | +- [Learn more about the change data capture resource](concepts-change-data-capture-resource.md) |
0 commit comments