An Azure service for ingesting, preparing, and transforming data at scale.
Hi Laurent Delaquis,
This happens due to Azure Data Factory (ADF) Copy Activity behavior when reading larger text files, especially from SFTP sources.
When ADF copies a delimited text file (such as CSV) from SFTP, it does not always read the file as a single stream. For smaller files, the file is read in one pass and the header row appears only once. However, when the file size exceeds a certain threshold, ADF may automatically switch to chunked (block‑based) reading for performance reasons.
In chunked processing, the file is read in multiple segments. For text-based files, the header row can be re-read at the start of a new chunk. ADF does not automatically suppress or remove duplicate headers during this process, so the header row gets written again into the output file, often appearing in the middle of the data.
As a result, the file created by the Copy Activity can contain the header record more than once, even though the source file has only a single header. This is a known and documented behavior of Copy Activity with certain connectors (such as SFTP) and is not caused by file appending or multiple source files being merged.
Microsoft has documented similar scenarios where chunked reads during Copy Activity can lead to duplicate rows or headers when processing large files from SFTP sources.
Mitigation: To avoid this behavior, disable chunking for the Copy Activity source or copy the file as‑is (binary copy) and handle header processing only during downstream ingestion.
Reference links:
Copy Activity internal behavior and processing model: https://learn.microsoft.com/en-us/azure/data-factory/copy-activity-overview
SFTP connector behavior in ADF: https://learn.microsoft.com/en-us/azure/data-factory/connector-sftp?tabs=data-factory
Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.
Please do not forget to "up-vote" wherever the information provided helps you, as this can be beneficial to other community members.