[英]azure function http trigger inputting cosmos db document
Referring to this azure documentation and this using parameters from http trigger 请参阅此Azure文档以及使用http触发器中的参数
It refers specifically to 它专门指
"id" : "{queueTrigger_payload_property}",
"partitionKey": "{queueTrigger_payload_property}",
If I have an javascript function, an http Trigger which provides a JSON packet in the body. 如果我具有javascript函数,则可以使用http触发器在主体中提供JSON数据包。 How do I use the Azure cosmos db bindings to get a document using the binding to pass the http json value to the cosmos db query? 如何使用Azure cosmos db绑定获取使用该绑定的文档,以将http json值传递给cosmos db查询?
I expect similar to this : 我期望与此类似:
"sqlQuery": "SELECT * from c where c.departmentId = {departmentId}",
except that the {departmentId}
should be a property from the httptrigger
(named req) ? 除了{departmentId}
应该是httptrigger
(命名为req)的属性httptrigger
?
thus the function.json looks like this: 因此function.json看起来像这样:
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req"
}, {
"type": "documentDB",
"name": "inputDocument",
"databaseName": "mydb",
"collectionName": "things",
"partitionKey": "/things/thingid",
"connection": "my_DOCUMENTDB",
"direction": "in",
"sqlQuery": "Select * from things s where s.thingid={httpTrigger_body_thingid}"
}
The http Trigger in javascript would look like this in the function, which works: req.body.thingid
, however binding to the input results in errors, "property not defined" so how do I use an HTTP Trigger input to get a value from a json packet to query cosmos db in the first input, all in the same function? javascript中的http触发器在该函数中看起来像这样: req.body.thingid
,但是绑定到输入会导致错误“属性未定义”,因此我该如何使用HTTP触发器输入来从中获取值一个json数据包,用于在第一个输入中查询cosmos db,所有功能都相同?
It should be just {thingid}
: 它应该只是{thingid}
:
{
"type": "documentDB",
"name": "inputDocument",
"databaseName": "mydb",
"collectionName": "things",
"connection": "my_DOCUMENTDB",
"direction": "in",
"sqlQuery": "select * from things s where s.thingid={thingid}"
}
For a POST request like 对于POST请求,例如
{
"thingid": "293a2fc3-799f-4669-92d3-3413f1afa51e"
}
it will deliver the documents in context.bindings.inputDocument
(javascript array). 它将在context.bindings.inputDocument
(javascript数组)中交付文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.