Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure函数-读取Blob数据[JS]_Azure_Azure Functions_Azure Storage Blobs - Fatal编程技术网

Azure函数-读取Blob数据[JS]

Azure函数-读取Blob数据[JS],azure,azure-functions,azure-storage-blobs,Azure,Azure Functions,Azure Storage Blobs,我正在尝试使用azure函数读取azure blob内容 var blobName = 'my-awesome-text-blob'; blobService.getBlobToText( containerName, blobName, function(err, blobContent, blob) { if (err) { console.error("Couldn't download blob %s",

我正在尝试使用azure函数读取azure blob内容

var blobName = 'my-awesome-text-blob';
blobService.getBlobToText(
    containerName,
    blobName,
    function(err, blobContent, blob) {
        if (err) {
            console.error("Couldn't download blob %s", blobName);
            console.error(err);
        } else {
            console.log("Sucessfully downloaded blob %s", blobName);
            console.log(blobContent);
        }
    });
容器名称始终相同,blob名称由触发函数的队列消息传递

var blobName = 'my-awesome-text-blob';
blobService.getBlobToText(
    containerName,
    blobName,
    function(err, blobContent, blob) {
        if (err) {
            console.error("Couldn't download blob %s", blobName);
            console.error(err);
        } else {
            console.log("Sucessfully downloaded blob %s", blobName);
            console.log(blobContent);
        }
    });
当我运行此函数时,函数超时(超过5分钟)

带有blob名称的队列消息是正确的并显示出来,blob只包含一个长的json,大约为292kb

我曾尝试在创建新blob时直接触发函数,但它返回一个带有流的对象,您知道任何使该流可读的方法吗

module.exports = async function (context, myBlob) {
    context.log("JavaScript blob trigger function processed blob \n Blob:", context.bindingData.blobTrigger, "\n Blob Size:", myBlob.length, "Bytes");
    context.log("type of the blob passed:",typeof(myBlob))
通过上面的代码,我正确地得到了blob的类型和长度

但如果我尝试打印它,我会得到:

( 2020-09-22 [Information] printing blob <Buffer 7b ....... )

(2020-09-22[信息]打印blob只需转换流:

module.exports = async function (context, myBlob) {
    context.log(context.bindings.myBlob.toString());
    context.log("JavaScript blob trigger function processed blob \n Blob:", context.bindingData.blobTrigger, "\n Blob Size:", myBlob.length, "Bytes");
};

非常感谢!我曾尝试使用此功能,但设置错误:)