Javascript 在Azure函数绑定中将队列触发器消息引用为JSON

Javascript 在Azure函数绑定中将队列触发器消息引用为JSON,javascript,node.js,azure-functions,Javascript,Node.js,Azure Functions,我试图在JavaScript Azure函数队列绑定中以JSON的形式访问队列触发消息,如下所示,但每次新队列消息到达时,我都会收到一个错误,即“blobTrigger未定义”。我可以看到队列消息JSON中的字段,那么有没有办法做到这一点,或者这是不可能的 { "bindings": [ { "type": "queueTrigger", "direction": "in", "name": "retryTrigger", "queue

我试图在JavaScript Azure函数队列绑定中以JSON的形式访问队列触发消息,如下所示,但每次新队列消息到达时,我都会收到一个错误,即“blobTrigger未定义”。我可以看到队列消息JSON中的字段,那么有没有办法做到这一点,或者这是不可能的

{
  "bindings": [
    {
      "type": "queueTrigger",
      "direction": "in",
      "name": "retryTrigger",
      "queueName": "azure-webjobs-retry"
    },
    {
      "name": "myBlob",
      "type": "blob",
      "direction": "in",
      "path": "{queueTrigger.blobTrigger}"
    }
  ]
}

您应该在队列触发器绑定中使用POCO对象,请参见以下示例:

使用Microsoft.Azure.WebJobs;
使用Microsoft.Extensions.Logging;
使用System.IO;
使用System.Threading.Tasks;
命名空间函数PP13
{
公共静态类函数9
{
[功能名称(“功能9”)]
公共静态异步任务运行(
[QueueTrigger(“azure webjobs重试”,Connection=“rk2018storagev2_STORAGE”)]有效负载myQueueItem,
[Blob(“{ContainerName}/{BlobName}”,FileAccess.Read,Connection=“rk2018storagev2_STORAGE”)]字符串myBlobItem,
ILogger日志)
{
LogInformation($“C#队列触发器函数已处理:{myQueueItem}”);
log.LogInformation($“Blob内容:{myBlobItem}”);
等待任务。完成任务;
}
}
公共类有效载荷
{
公共字符串容器名称{get;set;}
公共字符串BlobName{get;set;}
公共重写字符串ToString()
{
返回$“{ContainerName}/{BlobName}”;
}
}
}
对于门户网站:

run.csx:

using System;

public static async Task Run(Payload myQueueItem, string myBlobItem, ILogger log)
{
    log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");

    log.LogInformation($"Blob Content: {myBlobItem}");

    await Task.CompletedTask;

}

public class Payload
{
    public string ContainerName { get; set; }
    public string BlobName { get; set; }

    public override string ToString()
    {
        return $"{ContainerName}/{BlobName}";
    }
}
function.json:

{
  "bindings": [
    {
      "name": "myQueueItem",
      "type": "queueTrigger",
      "direction": "in",
      "queueName": "azure-webjobs-retry",
      "connection": "rk2018storagev2_STORAGE"
    },
    {
      "type": "blob",
      "name": "myBlobItem",
      "path": "{ContainerName}/{BlobName}",
      "connection": "rk2018storagev2_STORAGE",
      "direction": "in"
    }
  ],
  "disabled": false
}
测试:


我相信您可以将此文档中的
queueTrigger.blobName
简化为
blobName
,并调用JS


这假设队列消息是一个JSON负载,其属性在我的示例中称为
blobName

脚本在进入我的代码之前崩溃,出现“blobTrigger未定义”错误。负载(POCO)对象的外观如何?
{   
   "ContainerName":"test",
   "BlobName":"abc.json"
}