我正在实施队列触发器。发生了什么事情我通过队列收到pdf的网址,我将该pdf转换为png,然后我将该png上传到azure博客存储。我想将这个azure blob的新url添加到新队列中。当然我可以用azure存储SDK做到这一点。 instaed我想使用绑定。这就是我到目前为止所做的事情
function.json
{
"bindings": [{
"name": "pdffaxqueue",
"type": "queueTrigger",
"direction": "in",
"queueName": "pdffaxqueue",
"connection": "AzureWebJobsStorage"
},
{
"type": "queue",
"direction": "out",
"name": "myQueueItemii",
"queueName": "qsendtogettext",
"connection": "STORAGEConnectionString"
}],
"disabled": false
}
代码,我上传png azure blob服务并将url添加到队列
blobService.createBlockBlobFromLocalFile(CONTAINER_NAME, BLOCK_BLOB_NAME, './' + FileName, function(errorerror) {
if (error) {
context.res = {
status: 400,
headers: {
'Content-Type': 'application/json'
},
body: {
'__error': error
}
};
context.done();
}
//removing the image after uploding to blob storage
fs.unlinkSync('./' + FileName);
context.log(context.bindings)
context.bindings.myQueueItemii = [blobService.getUrl(CONTAINER_NAME, BLOCK_BLOB_NAME)];
context.log("added to the q")
});
但似乎它没有将url添加到队列中。我在这做错了什么
答案 0 :(得分:0)
您应该通过从context.done()
函数的回调中调用createBlockBlobFromLocalFile
来告知运行时代码已完成:
blobService.createBlockBlobFromLocalFile(CONTAINER_NAME, BLOCK_BLOB_NAME, './' + FileName, function(errorerror) {
// ...
context.log(context.bindings)
context.bindings.myQueueItemii = [blobService.getUrl(CONTAINER_NAME, BLOCK_BLOB_NAME)];
context.log("added to the q")
// Add this line here
context.done()
});