File Gets corrupted when downloading from SFTP Server

Sumit Gaur 390 Reputation points
2025-11-03T13:28:15.0166667+00:00

Hi,

we're experiencing an issue with the SFTP connector in logic app standard where files especially ZIP packages occasionally get corrupted after being picked up.

Our workflow uses an SFTP trigger with include content disabled followed by a Read File Content action which reads the zip package for further processing from the directory.

we have observed that in some case when we extract the zip package we get this issue: The service provider action failed with error code 'BadRequest' and error message 'Can't parse the provided ZIP file stream. Provide a valid ZIP compressed archive. Error: 'End of Central Directory record could not be found.

what we have seen that it also corrupts the file in the SFTP directory as well. the SFTP user don't have write permission to the directory. this doesn't seem to happen due to a race condition as we have seen this file already there and processed a bit later.

the trigger runs every 5 mins and have split-on enabled to pick multiple files and has include content as disabled.

what could be the reason behind this, looks like some connector bug.

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
{count} votes

Answer accepted by question author
  1. Sonny Gillissen 3,996 Reputation points Volunteer Moderator
    2025-11-07T12:46:45.7033333+00:00

    Hi Sumit Gaur

    Thanks for reaching out on Microsoft Q&A!

    The SFTP built-in connector in Logic App Standard uses streaming rather than chunking for file transfers. When you use include content = false in the trigger and then call Get file content, the connector streams the file again. Even though your SFTP user has no write permissions, the connector opens the file stream in a way that can truncate or lock the file during read operations. This is a bug in the connector implementation, not your permissions setup

    You can try two things to avoid the issue:

    • When applicable, disable Split-On or Set Concurrency = 1. This prevents multiple parallel reads that can corrupt the stream.
    • Use Get file content (V2) as V2 uses improved handling for streaming and avoids some corruption issues.
    • If possible, switch to the Managed SFTP connector. It uses chunking instead of streaming and is less prone to this issue.

    Please click ‘Accept answer’ if you think my answer is helpful. Feel free to drop additional queries in the comments below!

    Kind regards,

    Sonny


Answer accepted by question author
  1. Rupesh Asati 1,020 Reputation points Microsoft External Staff Moderator
    2025-11-03T16:45:51.9633333+00:00

    Hi Sumit Gaur,

    This situation involves Azure-based file polling and processing possibly through Logic Apps or API Management where file corruption is happening despite having concurrency turned off and limiting the maximum number of files per trigger run

    Use V2 Connectors

    If you're using Azure Logic Apps, switching to V2 connectors (if available) can help improve performance and reliability. V2 connectors are optimized for better scalability and error handling. Ensure you’re using the latest version of the connector for file polling.

    Verify File Integrity

    Corrupted files can occur due to incomplete writes or network issues during transfer. To mitigate this:

    • Check File Locks: Ensure the files being polled are not being written to or modified during the trigger run.

    Use Checksums: Implement checksum validation (e.g., MD5 or SHA256) to verify file integrity before processing.

    Retry Logic - Add retry policies in your workflow to handle transient issues.

    Enable Logging and Diagnostics

    Enable detailed logging in your workflow to identify the root cause of corruption

    Azure Monitor - Use Azure Monitor or Application Insights to track file processing and errors. Custom Logs - Log file names, sizes, and timestamps to detect patterns in corrupted files.

    I hope the provided answer is helpful,

    Please "Up Vote" if the information helped you. This will help us and others in the community as well.

    Thank you.Hi Sumit Gaur,

    This situation involves Azure-based file polling and processing possibly through Logic Apps or API Management where file corruption is happening despite having concurrency turned off and limiting the maximum number of files per trigger run

    Use V2 Connectors

    If you're using Azure Logic Apps, switching to V2 connectors (if available) can help improve performance and reliability. V2 connectors are optimized for better scalability and error handling. Ensure you’re using the latest version of the connector for file polling.

    Verify File Integrity

    Corrupted files can occur due to incomplete writes or network issues during transfer. To mitigate this:

    Check File Locks: Ensure the files being polled are not being written to or modified during the trigger run.

    Use Checksums: Implement checksum validation (e.g., MD5 or SHA256) to verify file integrity before processing.

    Retry Logic - Add retry policies in your workflow to handle transient issues.

    Enable Logging and Diagnostics

    Enable detailed logging in your workflow to identify the root cause of corruption

    Azure Monitor - Use Azure Monitor or Application Insights to track file processing and errors.

    Custom Logs - Log file names, sizes, and timestamps to detect patterns in corrupted files.

    I hope the provided answer is helpful,

    Please "Up Vote" if the information helped you. This will help us and others in the community as well.

    Thank you.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.