Search code examples
azureazure-data-factoryazure-data-lake

Using ADF to get a subset of files from the directory in Azure File Share


For example my Azure file share directory contains the following files:

abc_YYYYMMDD.txt
def_YYYYMMDD.txt
ijk_YYYYMMDD.txt

I'm only interested to get abc_YYYYMMDD.txt and ijk_YYYYMMDD.txt

Currently, I have a Get Metadata activity that gets a list of files (childItems property) inside a File Share directory.

Then I have Filter activity that has this dynamic content:

@startswith(item().name, variables('filename_filter')) OR startswith(item().name, 
variables('filename2filter')))

Unfortunately, it has an error:

Position 54 'startswith' is a primitive and doesn't support nested properties

How do I resolve this if I have multiple conditions inside the Dynamic Content for Filter activity?


Solution

  • Your Filter expression should be like this:

    @or(startswith(item().name,variables('filename_filter')),startswith(item().name,variables('filename2filter'))
    

    The expression doesn't support "or" directly, you should use or() function.

    This is my source folder: enter image description here

    I create a pipeline, using parameters to filter the filename which start with "test1" and "test2":

    enter image description here

    Run the pipeline: enter image description here

    Output: enter image description here

    HTH.