我一直在努力根据队列触发器中的数据定义表/blob 输出绑定。我意识到我可以通过代码中的命令式绑定来实现这一点,但我认为这也应该可以通过 functions.json 中的绑定来实现。我以为我已经解决了这个问题,但现在出现了一个奇怪的运行时错误,我无法通过搜索找到任何信息。
这是我正在使用的 functions.json 定义:
{
"bindings": [
{
"name": "myQueueItem",
"type": "queueTrigger",
"direction": "in",
"queueName": "w2pdfqueue",
"connection": "xxxxxxxx"
},
{
"type": "table",
"name": "FW2Table",
"tableName": "FW2",
"take": 1,
"connection": "xxxxxxxxx",
"direction": "in",
"partitionKey": "{PartitionKey}",
"rowKey": "{RowKey}"
},
{
"type": "blob",
"name": "outputBlob",
"path": "{ClientID}/{ResourceID}",
"connection": "xxxxxxxxxx",
"direction": "inout"
}
],
"disabled": false
}
这是我的运行语句:
public static void Run(W2QueueItem myQueueItem, TraceWriter log, W2Row FW2Table, CloudBlockBlob outputBlob)
最后,我尝试用于绑定的自定义队列消息:
public class W2QueueItem
{
public string PartitionKey { get; set; }
public string RowKey { get; set; }
public string ClientID { get; set; }
public string ResourceID { get; set; }
}
以上所有编译成功,但是在运行时我收到以下错误消息。我不知道如何继续 - 绑定到自定义队列消息的其他在线示例似乎没有遇到此类错误。欢迎大家提出意见!
ost: Binding parameters to complex objects (such as 'W2QueueItem') uses Json.NET serialization.
1. Bind the parameter type as 'string' instead of 'W2QueueItem' to get the raw values and avoid JSON deserialization, or
2. Change the queue payload to be valid json. The JSON parser failed: Unexpected character encountered while parsing value: s. Path '', line 0, position 0.
.
错误发生时消息队列的内容为:
{
"PartitionKey": "d6a2e537-a0a0-4949-a6fd-2e56723cdaf0",
"RowKey": "1|053e3136-048d-417b-94c0-6339d3b9c835",
"ClientID": "ef1de151-9855-54d7-4598-6ee416dc5a51",
"ResourceID": "a33efdd2-45ae-47ee-bc56-55b431468962",
"$AzureWebJobsParentId": "e1337646-5f0f-44e4-86fe-e6a46589a739"
}