{"id":1023,"date":"2021-01-27T01:27:40","date_gmt":"2021-01-27T01:27:40","guid":{"rendered":"http:\/\/jackofalltradesmasterofsome.com\/blog\/?p=1023"},"modified":"2021-02-05T14:35:12","modified_gmt":"2021-02-05T14:35:12","slug":"streaming-etl-with-azure-data-factory-and-create-a-parameter-driver-pipeline","status":"publish","type":"post","link":"https:\/\/jackofalltradesmasterofsome.com\/blog\/2021\/01\/27\/streaming-etl-with-azure-data-factory-and-create-a-parameter-driver-pipeline\/","title":{"rendered":"Streaming ETL with Azure Data Factory and CDC &#8211; Create a Parameter Driver Pipeline"},"content":{"rendered":"\n<p>In this series we look at building a Streaming ETL with Azure Data Factory and CDC &#8211; Create a Parameter Driver Pipeline. This is Part 6, The rest of the series is below.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><a href=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/2021\/01\/25\/streaming-etl-with-azure-data-factory-and-cdc-enabling-cdc\/\">Enabling CDC<\/a><\/li><li><a href=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/2021\/01\/25\/streaming-etl-with-azure-data-factory-and-cdc-setting-up-audit-tables\/\">Setting up Audit Tables<\/a><\/li><li><a href=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/2021\/01\/25\/streaming-etl-with-azure-data-factory-and-cdc-provisioning-azure-data-factory\/\">Provisioning Azure Data Factory<\/a><\/li><li><a href=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/2021\/01\/25\/streaming-etl-with-azure-data-factory-and-cdc-provisioning-provisioning-azure-blob-storage\/\">Provisioning Azure Blog Storage<\/a><\/li><li><a href=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/2021\/01\/27\/streaming-etl-with-azure-data-factory-and-cdc-creating-a-data-source-connection-in-azure-data-factory\/\">Create Data Source Connection in ADF<\/a><\/li><li><a href=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/2021\/01\/27\/streaming-etl-with-azure-data-factory-and-incremental-pipeline-azure-data-factory\/\">Create Incremental Pipeline in ADF<\/a><\/li><li><a href=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/2021\/01\/27\/streaming-etl-with-azure-data-factory-and-create-a-parameter-driver-pipeline\/\">Create a Parameter Driven Pipeline<\/a><\/li><li><a href=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/2021\/01\/27\/streaming-etl-with-azure-data-factory-and-cdc-creating-the-rolling-etl-window\/\">Create a Rolling Trigger<\/a><\/li><\/ol>\n\n\n\n<p>This series uses the Adventureworks database. For more information on how to get that set up see my Youtube video for <a href=\"https:\/\/www.youtube.com\/watch?v=JsrQGU7rhYA\">Downloading <\/a>and <a href=\"https:\/\/www.youtube.com\/watch?v=YL4-wMriI8s\">Restoring<\/a> the database.  <\/p>\n\n\n\n<p>The previous step will\npull all the changes in the CDC table, but we do not want to do this all the\ntime. So let\u2019s look at creating a rolling window for the CDC ETL.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Navigate to the parameters section and create a new parameter. Add two paramenters \u201ctriggerStartTime\u201d and triggerEndTime\u201d and set them to yesterday and todays date in the format \u201c2020-01-07 12:00:00:000\u201d<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"460\" height=\"283\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-55.png\" alt=\"\" class=\"wp-image-1059\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-55.png 460w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-55-300x185.png 300w\" sizes=\"auto, (max-width: 460px) 100vw, 460px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"562\" height=\"190\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-56.png\" alt=\"\" class=\"wp-image-1060\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-56.png 562w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-56-300x101.png 300w\" sizes=\"auto, (max-width: 562px) 100vw, 562px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>On the Lookup Activity, update the query in the settings to the following to use the new variables. SQL Agent must be running for this step the parameters must be valid dates.<\/li><\/ul>\n\n\n\n<p>@concat(&#8216;DECLARE @begin_time\ndatetime, @end_time datetime, @from_lsn binary(10), @to_lsn binary(10); <\/p>\n\n\n\n<p>SET @begin_time =\n&#8221;&#8217;,pipeline().parameters.triggerStartTime,&#8221;&#8217;;<\/p>\n\n\n\n<p>SET @end_time =\n&#8221;&#8217;,pipeline().parameters.triggerEndTime,&#8221;&#8217;;<\/p>\n\n\n\n<p>SET @from_lsn =\nsys.fn_cdc_map_time_to_lsn(&#8221;smallest greater than or equal&#8221;, @begin_time);<\/p>\n\n\n\n<p>SET @to_lsn = sys.fn_cdc_map_time_to_lsn(&#8221;largest\nless than&#8221;, @end_time);<\/p>\n\n\n\n<p>SELECT count(1) changecount FROM cdc.fn_cdc_get_all_changes_dbo_DimProduct (@from_lsn, @to_lsn, &#8221;all&#8221;)&#8217;)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"452\" height=\"206\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-57.png\" alt=\"\" class=\"wp-image-1061\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-57.png 452w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-57-300x137.png 300w\" sizes=\"auto, (max-width: 452px) 100vw, 452px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Navigate back to the \u201cTrue\u201d condition and paste\nthe following query in to track the changes with the variables as well<\/li><\/ul>\n\n\n\n<p>@concat(&#8216;DECLARE @begin_time\ndatetime, @end_time datetime, @from_lsn binary(10), @to_lsn binary(10); <\/p>\n\n\n\n<p>SET @begin_time =\n&#8221;&#8217;,pipeline().parameters.triggerStartTime,&#8221;&#8217;;<\/p>\n\n\n\n<p>SET @end_time =\n&#8221;&#8217;,pipeline().parameters.triggerEndTime,&#8221;&#8217;;<\/p>\n\n\n\n<p>SET @from_lsn =\nsys.fn_cdc_map_time_to_lsn(&#8221;smallest greater than or equal&#8221;, @begin_time);<\/p>\n\n\n\n<p>SET @to_lsn =\nsys.fn_cdc_map_time_to_lsn(&#8221;largest less than&#8221;, @end_time);<\/p>\n\n\n\n<p>SELECT * FROM cdc.fn_cdc_get_all_changes_dbo_DimProduct(@from_lsn, @to_lsn, &#8221;all&#8221;)&#8217;)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"527\" height=\"244\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-58.png\" alt=\"\" class=\"wp-image-1062\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-58.png 527w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-58-300x139.png 300w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Edit the Sink tab in the true statement and click on parameters.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"491\" height=\"39\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-59.png\" alt=\"\" class=\"wp-image-1063\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-59.png 491w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-59-300x24.png 300w\" sizes=\"auto, (max-width: 491px) 100vw, 491px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"294\" height=\"54\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-60.png\" alt=\"\" class=\"wp-image-1064\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Add a new parameter called triggerStart<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"489\" height=\"136\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-61.png\" alt=\"\" class=\"wp-image-1065\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-61.png 489w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-61-300x83.png 300w\" sizes=\"auto, (max-width: 489px) 100vw, 489px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Head back to the Connections Tab for the dataset where we will be adding dynamic content for the directory and file.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"469\" height=\"112\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-62.png\" alt=\"\" class=\"wp-image-1066\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-62.png 469w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-62-300x72.png 300w\" sizes=\"auto, (max-width: 469px) 100vw, 469px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Add the following for the directory and file\nsections.<\/li><\/ul>\n\n\n\n<p><strong>Directory<\/strong><\/p>\n\n\n\n<p>@concat(&#8216;dimProduct\/incremental\/&#8217;,formatDateTime(dataset().triggerStart,&#8217;yyyy\/MM\/dd&#8217;))    <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"478\" height=\"114\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-63.png\" alt=\"\" class=\"wp-image-1067\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-63.png 478w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-63-300x72.png 300w\" sizes=\"auto, (max-width: 478px) 100vw, 478px\" \/><\/figure>\n\n\n\n<p><strong>File<\/strong><\/p>\n\n\n\n<p>@concat(formatDateTime(dataset().triggerStart,&#8217;yyyyMMddHHmmssf<\/p>\n\n\n\n<p>ff&#8217;),&#8217;.csv&#8217;)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"469\" height=\"180\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-64.png\" alt=\"\" class=\"wp-image-1068\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-64.png 469w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-64-300x115.png 300w\" sizes=\"auto, (max-width: 469px) 100vw, 469px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Navigate back to the Sink in the Copy and expand dataset properties. Add the dynamic content for the new parameter.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"530\" height=\"138\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-65.png\" alt=\"\" class=\"wp-image-1069\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-65.png 530w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2021\/01\/image-65-300x78.png 300w\" sizes=\"auto, (max-width: 530px) 100vw, 530px\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\"><li>You can now trigger your run and see the new files landing in the datalake.<\/li><\/ol>\n\n\n\n<p>Streaming ETL with Azure Data Factory and CDC &#8211;  Create a Parameter Driver Pipeline <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this series we look at building a Streaming ETL with Azure Data Factory and CDC &#8211; Create a Parameter Driver Pipeline. This is Part 6, The rest of the series is below. Enabling CDC Setting up Audit Tables Provisioning Azure Data Factory Provisioning Azure Blog Storage Create Data Source Connection in ADF Create Incremental [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":822,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,28,27,11,1],"tags":[104],"class_list":["post-1023","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","category-azure","category-big-data","category-data-warehouse","category-uncategorized","tag-azure-data-factory"],"_links":{"self":[{"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/posts\/1023","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/comments?post=1023"}],"version-history":[{"count":2,"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/posts\/1023\/revisions"}],"predecessor-version":[{"id":1079,"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/posts\/1023\/revisions\/1079"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/media\/822"}],"wp:attachment":[{"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/media?parent=1023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/categories?post=1023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/tags?post=1023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}