我试图检查我的azure函数(CosmosDB触发器)是否可以查看CosmosDB数据库中的文档,当我在Visual Studio中构建项目时遇到此错误。
[26-11-2018 12:08:51] Host started (33917ms)
[26-11-2018 12:08:51] Job host started
[26-11-2018 12:08:51] The following 1 functions are in error:
[26-11-2018 12:08:51] Function1: The listener for function 'Function1' was unable to start. Microsoft.Azure.Documents.Client: Service is currently unavailable.
[26-11-2018 12:08:51] Microsoft.Azure.Documents.Client: The requested resource is no longer available at the server.
[26-11-2018 12:08:53] Retrying to start listener for function 'Function1' (Attempt 1)
[26-11-2018 12:08:53] A ScriptHost error has occurred
[26-11-2018 12:08:53] The listener for function 'Function1' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: Object reference not set to an instance of an object.
我已经多次重启PC和Visual Studio,并且还更新了Visual Studio,我再次检查了连接字符串,但仍然遇到相同的错误。有人知道这意味着什么吗?哪里有问题?
我拥有的代码是Azure功能的标准代码:
public static class Function1
{
[FunctionName("Function1")]
public static void Run([CosmosDBTrigger(
databaseName: "cosmostest",
collectionName: "Items",
ConnectionStringSetting = "DBConnection",
LeaseCollectionName = "leases")]IReadOnlyList<Document> documents, TraceWriter log)
{
if (documents != null && documents.Count > 0)
{
log.Verbose("Documents modified " + documents.Count);
log.Verbose("First document Id " + documents[0].Id);
}
}
}