简体   繁体   中英

Event based trigger in azure data factory

For the below scenario where the left side is my source and the Right side is the destination:

Source                                                   Destination
----------                                               -----------------
sourceContainer/StaticFiles/Finance/X1.tsv               DestinationContainer/StaticFiles/Finance/X1.tsv
sourceContainer/StaticFiles/Customer/X2.tsv              DestinationContainer/StaticFiles/Customer/X2.tsv

I would want to place files at any of the source locations one at a time and it should trigger a copy pipeline to create path dynamically for destination. I have used one copy activity in a pipeline where I have created triggers for each like Finance and Customer.

I have referred to the below link, but no luck https://docs.microsoft.com/en-us/azure/data-factory/how-to-create-event-trigger

We need use Get Metadata and ForEach activities to achieve that. I created a simple test to copy files and create path dynamically for destination.

  1. First, we need to add a event trigger. Specify your container and path.
    在此处输入图像描述

  2. Declare a dataset of your container. 在此处输入图像描述

  3. At Get Metadata1, select the dataset declared previously, then select Child items. 在此处输入图像描述

  4. At ForEach1 activity, add dynamic content @activity('Get Metadata1').output.childItems to the Items . 在此处输入图像描述

  5. Inside ForEach1 activity, we can define a Copy activity. Select Wildcard file path and add StaticFiles to the path. 在此处输入图像描述

  6. At sink tab, we create a dataset to the destination container. 在此处输入图像描述 Here is output . Then add dynamic content and type in @item().name . It will create path dynamically for destination. 在此处输入图像描述

Debug:
The pipeline triggered when I upload a file to the StaticFiles/finance folder. 在此处输入图像描述 We can see it created path dynamically for destination. 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM