【发布时间】:2018-03-14 12:05:17
【问题描述】:
我目前正在 Azure 上创建一个 C# 函数应用,由计时器触发器和 CosmosDB 输入激活。对于这个应用程序,function.json 是
{
"bindings": [
{
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 */5 * * * *"
},
{
"type": "documentDB",
"name": "documents",
"databaseName": "database",
"collectionName": "collection",
"connection": "hellocloud_DOCUMENTDB",
"direction": "in"
}
],
"disabled": false
}
函数代码如下
#r "Microsoft.Azure.Documents.Client"
using System;
using Microsoft.Azure.Documents;
using System.Collections.Generic;
public static void Run(TimerInfo myTimer, IReadOnlyList<Document> documents,
TraceWriter log)
{
log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
log.Info("Documents modified " + documents.Count);
}
如果我保存此代码,我会从控制台日志中收到此错误
2018-03-14T10:31:36.739 [Info] Compilation succeeded.
2018-03-14T10:31:37.425 [Error] Microsoft.Azure.WebJobs.Host: Error indexing
method 'Functions.HelloCloudFunction'.
Microsoft.Azure.WebJobs.Extensions.DocumentDB: 'Id'
is required when binding to a IReadOnlyList`1 property.
在绑定中使用 id 我没有这个错误,但我认为有问题,因为我想选择整个集合而不是单个文档。有人可以帮忙吗?
【问题讨论】:
标签: c# azure azure-functions azure-cosmosdb