Connection Timeout and Internal Server Error 500 with Azure Function Handling Large Files from ADLS Gen 2

Mayur Patil 35 Reputation points
2025-03-26T05:20:13.4666667+00:00

I have created a function in my local environment that performs the following tasks: it reads files from ADLS Gen 2, uploads them to a temporary directory, truncates specific fields, and resizes the data to a maximum size of 3900. After these modifications, the files are uploaded back to ADLS Gen 2. This function works seamlessly for smaller files (approximately 1 MB). However, for larger files, I implemented chunking to read data from storage, which takes around 5 minutes. The issue arises when attempting to upload the modified file—it results in a 'connection timeout' error. This issue persists even when chunking is utilized, both in the local environment and in Azure Function. Additionally, for larger files, the Azure Function using a consumption plan throws an 'Internal Server Error 500.' I am seeking advice on resolving these problems.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,930 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Alex Burlachenko 10,335 Reputation points
    2025-03-26T07:36:25.6733333+00:00

    Hello Mayur Patil,

    thanks for post your questio here, so I can see 2 ways short term and long term...

    short term fix:

    implement chunked uploads with a 4 MB chunk size and a 300-second timeout in the SDK. Increase the function timeout to 10 minutes in host.json. Add retry logic for uploads.

    long term (probably solutions):

    switch to the premium plan for longer timeouts and better resource allocation. Optimize memory usage with streaming and incremental uploads. Monitor ADLS Gen 2 metrics to adjust concurrency if needed.

    By addressing both the timeout (via chunking and retries) and the 500 error (via timeout extension or plan upgrade), your function should handle large files more reliably.

    Best regards,

    Alex

    P.S. If my answer help to you, please Accept my answer


Your answer

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