An Azure service for ingesting, preparing, and transforming data at scale.
Justin Doh hi & thx for sharing urs issue here at Q&A portal,
Get Metadata can list files and inspect properties such as name, size, or modification time, but it doesn’t validate CSV headers or inspect the file contents. That’s why the bad file still reaches Copy Activity.
A better pipeline structure is
Get Metadata (childItems) > Filter by filename > ForEach > Lookup first row > If Condition > Copy Data
Inside the loop, use a parameterized CSV dataset pointing to @item().name. Configure the Lookup activity with firstRowOnly = true, but set First row as header to false. This makes ADF return the physical first line as values such as Prop_0, Prop_1, etc., rather than interpreting "There is no data to report." as a column name. Lookup supports returning only the first row of a delimited-text file.
The If Condition can then check either for the rejection message
@not(
contains(
string(activity('Lookup_First_Row').output.firstRow),
'There is no data to report'
)
)
Or, preferably, validate the expected header values explicitly:
@and(
equals(activity('Lookup_First_Row').output.firstRow.Prop_0, 'ExpectedColumn1'),
equals(activity('Lookup_First_Row').output.firstRow.Prop_1, 'ExpectedColumn2'),
equals(activity('Lookup_First_Row').output.firstRow.Prop_2, 'ExpectedColumn3')
)
Run Copy Data only through the True branch. In the False branch, move the file to a rejected folder, log its filename, or simply skip it.
Keep the Copy Activity’s actual source dataset configured with First row as header = true. Use a separate dataset for the Lookup validation with First row as header = false. Otherwise ADF may interpret the bad message as a header before your condition can validate it.
rgds,
Alex
&
If my answer was helpful pls mark it and additional thx if u follow me at Q&A portal
and at my blog https://ctrlaltdel.blog/