具有输入数据存储绑定的队列触发 Azure 函数

Azure function trigger by queue with input data storage binding

我正在尝试为队列触发功能设置输入数据存储绑定。

VTRequest 是一个被推送到队列的对象,VTEntity 是一个保存在数据库中的对象。

如果 function.json

{
  "bindings": [
    {
      "name": "vtAPIRequest",
      "type": "queueTrigger",
      "direction": "in",
      "queueName": "vtqueue",
      "connection": "vt_STORAGE"
    },
    {
      "type": "table",
      "name": "outVTAPIDataTable",
      "tableName": "data",
      "connection": "vt_STORAGE",
      "direction": "out"
    },
    {
      "type": "table",
      "name": "vtDataRow",
      "tableName": "VTData",
      "partitionKey": "VT",
      "rowKey": "{queueTrigger}.{hash}",
      "take": 1,
      "connection": "vt_STORAGE",
      "direction": "in"
    }
  ],
  "disabled": false
}

using System;


public class VTEntity {

    public string PartitionKey { get; set; }
    public String RowKey { get; set; }
    public string hash { get; set; }
    public string userID { get; set; }    
}



public class VTRequest {

    public string hash { get; set; }
    public string userID { get; set; }    
}


public static void Run(VTRequest vtAPIRequest, VTEntity vtDataRow, 
        TraceWriter log, IAsyncCollector<VTEntity> outVTAPIDataTable) {


    if(null != vtDataRow) {
       .....
    }

}

这是我收到的错误日志:

2017-10-09T12:06:07.840 Exception while executing function: Functions.VTAPIQueue. Microsoft.Azure.WebJobs.Host: Exception binding parameter 'vtDataRow'. Microsoft.Azure.WebJobs.Host: '{
  "hash": "asdasdasd",
  "userID": "123456789",
  "$AzureWebJobsParentId": "1f31be54-ec0d-4f0d-a4aa-45513d038f7e"
}.asdasdasd' is not a valid value for a partition key or row key.
2017-10-09T12:06:07.887 Function completed (Failure, Id=29268e32-0545-49c9-9f15-268d90de54cc, Duration=115ms)

我在相关数据库中确实有这条记录:

我想在数据库中查询队列对象传递的哈希 vtAPIRequest.hash

有办法吗?

你就快完成了,只需将 rowKey 的绑定更改为

"rowKey": "{hash}",