简体   繁体   中英

Azure function trigger by queue with input data storage binding

I'm trying to have an input data storage binding for queue triggering function.

VTRequest is an object that been pushed to the queue and the VTEntity is an object that been saved in the db.

this if the 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) {
       .....
    }

}

This is the error logs that i'm getting:

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)

and I do have this record in the related db:

在此处输入图片说明

I would like to query the DB for the hash that is been passed by the queue object vtAPIRequest.hash

is there a way to do so?

rowKey了,只需将rowKey的绑定rowKey

"rowKey": "{hash}",

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM