Azure Functions - NodeJS - Response Body as a Stream
azure, azure-functions, node.js
Solution
Unfortunately we don't have streaming support implemented in NodeJS just yet - it's on the backlog: https://github.com/Azure/azure-webjobs-sdk-script/issues/1361
If you're not tied to NodeJ open to using a C# function instead, you can use the storage sdk object directly in your input bindings and stream request output, instead of using the intermediate object approach.
Problem
I'd like to return a file from Blob Storage when you hit a given Azure Function end-point. This file is binary data. Per the Azure Storage Blob docs, the most relevant call appears to be the following since its the only one that doesn't require writing the file to an interim file: ` getBlobToStream ` However this call gets the Blob and writes it to a stream. Is there a way with Azure Functions to use a Stream as the value of res.body so that I can get the Blob Contents from storage and immediately write it to the response? To add some code, trying to get something like this to work: ``` 'use strict'; const azure = require('azure-storage'), stream = require('stream'); const BLOB_CONTAINER = 'DeContainer'; module.exports = function(context){ var file = context.bindingData.file; var blobService = azure.createBlobService(); var outputStream = new stream.Writable(); blobService.getBlobToStream(BLOB_CONTAINER, file, outputStream, function(error, serverBlob) { if(error) { FileNotFound(context); } else { context.res = { status: 200, headers: { }, isRaw: true, body : outputStream }; context.done(); } }); } function FileNotFound(context){ context.res = { status: 404, headers: { "Content-Type" : "application/json" }, body : { "Message" : "No esta aqui!."} }; context.done(); } ```