我有以下配置:
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": ["post"],
"route": "migrate/events/"
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"name": "documents",
"type": "cosmosDB",
"direction": "in",
"databaseName": "MyDatabase",
"collectionName": "{name}",
"sqlQuery": "SELECT * FROM c where c._ts >= {ts} ORDER BY c._ts OFFSET 0 LIMIT 3",
"connectionStringSetting": "CosmosDBConnection"
},
...
}
我用下面的请求体调用端点。
{
"name": "MyEvents",
"ts": 1620712053
}
在函数中,我可以看到req.body
上的属性是可用的,但documents
数组是空的。
用实际值替换{ts}
属性会得到一个包含3个文档的数组。
"sqlQuery": "SELECT * FROM c where c._ts >= 1620712053 ORDER BY c._ts OFFSET 0 LIMIT 3",
因此,它适用于注入{name}
的collectionName
,但不适用于应该注入{ts}
的sqlQuery
。
我也试着用routedata"route": "migrate/events/{name}/{ts}"
和查询{Query.ts}
但没有任何运气。
我以前遇到过这个问题,目前这在sqlQuery
的绑定中被阻止了. 如前所述,here
"为了防止注入攻击,任何绑定中使用的字符串SqlQuery属性在发送到之前被替换为SqlParameter你的文档数据库。">
您可以遵循此替代方法,