参考此
azure documentation
还有这个
using parameters from http trigger
具体指
"id" : "{queueTrigger_payload_property}",
"partitionKey": "{queueTrigger_payload_property}",
如果我有一个javascript函数,一个http触发器,它在主体中提供一个JSON数据包。如何使用Azure cosmos db绑定获取文档,使用绑定将http json值传递给cosmos db查询?
我希望类似的情况:
"sqlQuery": "SELECT * from c where c.departmentId = {departmentId}",
除了
{departmentId}
应为
httptrigger
(命名请求)?
因此,功能。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}"
}
javascript中的http触发器在函数中如下所示,其工作原理如下:
req.body.thingid
然而,绑定到输入会导致错误,“property not defined”,那么如何使用HTTP触发器输入从json数据包中获取一个值,以便在第一个输入中查询cosmos db,所有这些都在同一个函数中?