How to add a validation in azure data factory pipeline to check file size?

3.8k views Asked by At

I have multiple data sources I want to add a validation in azure data factory before loading into tables it should check for file size so that it is not empty. So if the file size is more than 10 kb or if it is not empty loading should start and if it is empty then loading should not start. I checked validation activity in Azure Data Factory but it is not showing size for multiple files in a folder. Any suggestions appreciated basically if I can add any python notebook for this validation will also do.

2

There are 2 answers

4
JSWilson On

Use GetMetadata under General Activities, then send the result to an If Condition. Get Metadata for File

You will then need to get the file size from the Dataset.@item().name is the name of the file you want to get the size of. Get File Size

If you are working with a directory do the following: Get Metadata for content of folder

Get child items Then check the file size of each file.

This is what the ForEach settings looks like. Then you can use @item().name inside the ForEach to get at the file.

For Each Settings

The data source will need to have the parameter FileName. Parameters for Datasource

0
HarithaMaddi-MSFT On

Following GIF shows step by step process on how to achieve the above requirement in ADF.

enter image description here