Accessing file name from nested folder structure and passing it to Notebook activity as a parameter in ADF.

Vinay5 46 Reputation points
2021-05-03T18:26:05.047+00:00

Hello,

I have around 6 files in a nested folder structure as below.

data/year/Month/Day/time
File1.xml
File2.xml
... File6.xml.

I have to pass each file as a parameter to 6 different notebook activities.

So, I started to pass File1.xml as a parameter to a notebook activity. I used getmetadata activity and in field list I selected child items. It is giving only the year folder as output. I am unable to access file name from the nested folder.

Could you please let me know how to achieve this output.

Thank you.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,185 questions
{count} votes

Accepted answer
  1. KranthiPakala-MSFT 46,442 Reputation points Microsoft Employee
    2021-05-04T23:02:51.887+00:00

    Hi @Vinay5 ,

    Here is the GIF of my pipeline. See if that helps:

    93729-nestedfolderdata.gif

    Below are screenshots of Getmetadata activity from second/child pipeline in which we get the file names from time folder:

    1. Dataset parameters:
      93677-image.png
    2. Dataset connection dynamic expression:
      93697-image.png
    3. GetMetada settings:
      93659-image.png

    Hope this helps.

    ----------

    Please don’t forget to Accept Answer and Up-Vote wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. KranthiPakala-MSFT 46,442 Reputation points Microsoft Employee
    2021-05-03T22:38:16.62+00:00

    Hi @Vinay5 ,

    Thanks for reaching out. As per my understanding I assume that you might be pointing your dataset file path to '/data/' and hence you are just receiving the year folder name.

    In order to get the file name list, you will have to point your dataset file path to the sub-folder where the files are actually located.

    For example as below:

    93395-image.png

    Which will result all the files inside the subfolder pointed in the file path of your dataset in Getmetadata activity.

    93370-image.png

    In case if you need to pass the year/month/date dynamically then you will have to declare dataset parameter for each (for year, month & date) and then use concatenation function to form the file path in Dataset connection settings. And in GetMetadata activtiy level you can use dynamic expression to get the year, month and date values based on your requirement.

    Concatenation expression used in below sample: @concat('input/',dataset().ds_yearFolder,'/',dataset().ds_monthFolder,'/',dataset().ds_dateFolder)

    Below is a sample GIF (Please note that in this sample I am passing static values for year, month & date to dataset parameters)

    93326-dynamicdatefolder.gif

    Hope this helps. Do let us know if you have further query.

    ----------

    Please don’t forget to Accept Answer and Up-Vote wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.

  2. Vinay5 46 Reputation points
    2021-05-05T15:31:36.05+00:00

    Hi Kranthi,

    Thanks for the detailed explanation. I go the output as required.