所以我从this page读到的是,我应该能够:
数字1,2和4正在运作。但是如何使用路径中的ID从DocumentDB获取文档?
我可以在DocumentDb输入中使用代理路由中的{path}
吗?
我有一个像这样定义的代理。
{
"$schema": "http://json.schemastore.org/proxies",
"proxies": {
"index": {
"matchCondition": {
"route": "{*path}",
"methods": [
"GET"
]
},
"backendUri": "https://%WEBSITE_SITE_NAME%.azurewebsites.net/api/Index"
},
"api": {
"matchCondition": {
"route": "api/{*path}"
},
"backendUri": "https://%WEBSITE_SITE_NAME%.azurewebsites.net/api/{path}"
},
"index existing subscription": {
"matchCondition": {
"route": "/subscription/{*path}",
"methods": [
"GET"
]
},
"backendUri": "https://%WEBSITE_SITE_NAME%.azurewebsites.net/api/IndexSubscription/{path}"
}
}
}
答案 0 :(得分:0)
以下是带有文档数据库输入绑定的函数示例。
function.json
{
"bindings": [
{
"authLevel": "function",
"name": "req",
"type": "httpTrigger",
"direction": "in",
"route": "MyDocFunc/{docid}"
},
{
"type": "documentDB",
"name": "inputDocument",
"databaseName": "MyDocDB",
"collectionName": "MyCollection",
"id": "{docid}",
"connection": "mydocdb_DOCUMENTDB",
"direction": "in"
},
{
"name": "$return",
"type": "http",
"direction": "out"
}
],
"disabled": false
}
csx
public static async Task<HttpResponseMessage> Run(
HttpRequestMessage req, string docid, string inputDocument)
{
return req.CreateResponse(HttpStatusCode.OK, inputDocument);
}
代理的使用不会对此产生太大影响......您可以将代理参数传递给函数参数。