【发布时间】:2020-07-06 09:38:11
【问题描述】:
我是 Azure Functions 和 Cosmos DB 的新手。我正在尝试在我的本地计算机上设置一个 Azure 函数,该函数会在通过 Visual Studio 更新 Cosmos DB 时触发。
最初,我收到了错误 Unable to resolve app setting for property CosmosDBTriggerAttribute.ConnectionStringSetting,但在关注此 solution 后,我能够解决该错误,但现在得到:
The listener for function 'Function1' was unable to start. System.Net.Http: No such host is known. System.Private.CoreLib: No such host is known.
这是我的local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"connectionString": "AccountEndpoint=https://<collectionName>.documents.azure.com:443/;AccountKey=<key>"
}
}
如果有用的话,这是我的运行方法:
public static void Run([CosmosDBTrigger(
databaseName: "DB-Name",
collectionName: "CollectionName",
ConnectionStringSetting = "String I used while setting up the project in VS",
LeaseCollectionName = "leases")]IReadOnlyList<Document> input, ILogger log)
{
if (input != null && input.Count > 0)
{
log.LogInformation("Documents modified " + input.Count);
log.LogInformation("First document Id " + input[0].Id);
}
}
有人可以帮忙吗?我的另一个问题是 Account Key 在这种情况下是什么?我目前在我的 Cosmos DB 帐户中使用该应用名称。
【问题讨论】:
标签: azure azure-functions azure-cosmosdb