POST a 50MB file to an Azure Durable Function app

29 Views Asked by At

In my Azure Durable Function (DF) app, the Client function HttpStart is to receive a 50MB file, write it to Blob storage, pass the descriptor to the Orchestration function and return 202 Accepted with query and control URIs as JSON.

As soon as I include even a 5MB file in the POST request body, Azure returns a 500 Internal Server Error.

Starting with the tutorial code for HelloSequence:

const df = require("durable-functions");

module.exports = async function (context, req) {
    const client = df.getClient(context);
    const instanceId = await client.startNew(req.params.functionName, undefined, req.body);

    context.log(`Started orchestration with ID = '${instanceId}'.`);

    return client.createCheckStatusResponse(context.bindingData.req, instanceId);
};

returns 202 with no file in the request body. I expected the same response when I included a file in the POST request body.

But including a file of even 5MB in the POST returns 500 Internal Server Error. The portal filesystem log shows:

2024-03-27T13:36:57.185 [Information] Executing 'Functions.HttpStart' (Reason='This function was programmatically called via the host APIs.', Id=5c6b431f-381f-46c4-b638-e0946b0a80ba)
2024-03-27T13:36:57.797 [Error] Executed 'Functions.HttpStart' (Failed, Id=5c6b431f-381f-46c4-b638-e0946b0a80ba, Duration=1434ms)Result: FailureException: Request body larger than maxBodyLength limitStack: Error [ERR_FR_MAX_BODY_LENGTH_EXCEEDED]: Request body larger than maxBodyLength limitat RedirectableRequest.write (C:\home\site\wwwroot\node_modules\follow-redirects\index.js:148:24)at RedirectableRequest.end (C:\home\site\wwwroot\node_modules\follow-redirects\index.js:173:10)at dispatchHttpRequest (C:\home\site\wwwroot\node_modules\axios\lib\adapters\http.js:328:11)at new Promise (<anonymous>)at httpAdapter (C:\home\site\wwwroot\node_modules\axios\lib\adapters\http.js:46:10)at dispatchRequest (C:\home\site\wwwroot\node_modules\axios\lib\core\dispatchRequest.js:53:10)at Axios.request (C:\home\site\wwwroot\node_modules\axios\lib\core\Axios.js:108:15)at Axios.<computed> [as post] (C:\home\site\wwwroot\node_modules\axios\lib\core\Axios.js:140:17)at Function.wrap [as post] (C:\home\site\wwwroot\node_modules\axios\lib\helpers\bind.js:9:15)at DurableOrchestrationClient.<anonymous> (C:\home\site\wwwroot\node_modules\durable-functions\lib\src\durableorchestrationclient.js:397:55)

Note that the HttpStart code is unchanged, and ignores the file in the request body.

Azure Function - HTTP trigger request length exceeded refers to a hard 100MB limit on uploads to DF Client functions; 5MB is only a fraction of that.

An open issue suggests best practice is:

  1. Upload to Blob storage, secure file descriptor
  2. HTTP GET or POST to DF API with file descriptor

This seems onerous for a 5MB value and requires the remote process responsible for managing the Blob storage, an unnecessary complication.

How do I get a DF Client function to receive a 5MB file in the POST request body?

0

There are 0 best solutions below