dxthegreat dxthegreat - 7 months ago 277
Node.js Question

How to parse Multi-part form data in an Azure Function App with HTTP Trigger? (NodeJS)

I want to write a NodeJS HTTP endpoint using Azure Functions.

This endpoint will be a POST endpoint which takes files and upload these to blob storage.

However, NodeJS multipart form data parsers are all in the form of httpserver or expressJS middleware.

Is there any available tools that can parse the multipart form data after it has all been received from the Function Application's wrapper?



As Azure Functions has wrapped http server object in Node.js, and exposes a simple req and context with several functionalities, refer to https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node#exporting-a-function for details.

And mostly, Azure Functions is designed for triggers and webhooks requests, you can refer to https://docs.microsoft.com/en-us/azure/azure-functions/functions-compare-logic-apps-ms-flow-webjobs for the detailed comparison.

Meanwhile, you can try the answer of Image upload to server in node.js without using express to parse the request body content to file content, and upload to Azure Storage leveraging Azure Storage SDK for node.js, you can install custom node modules via KUDU console. Refer to https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node#node-version--package-management for more info.

And I suggest you can try to leverage Azure API App in node.js to approach your requiremnet. As it is an expressjs based project, which will be more easier to handle upload files.

Any further concern, please feel free to let me know.