[英]Azure function in node.js with Cosmos DB binding doesn't get properties injected into sqlQuery
我有以下配置。
{
"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
}
在 function 中,我可以看到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}
但沒有任何運氣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.