- 我正在设置 @CosmosDBTrigger,需要有关以下代码的帮助以及名称字段中需要包含哪些内容?
我正在使用以下技术堆栈,
JDK 1.8.0-211 Apache maven 3.5.3 AzureCLI 2.0.71 .net核心2.2.401 Java: 公共(public)类函数{ @FunctionName("CosmosTrigger")
public void mebershipProfileTrigger(
@CosmosDBTrigger(name = "?", databaseName =
"*database_name*", collectionName = "*collection_name*",
leaseCollectionName = "leases",
createLeaseCollectionIfNotExists = true,
connectionStringSetting = "DBConnection") String[] items,
final ExecutionContext context) {
context.getLogger().info("item(s) changed");
}
}
我们需要在名称字段中提供什么?
本地.settings.json
{
"IsEncrypted": false,
"Values": {
"DBConnection": "AccountEndpoint=*Account_Endpoint*"
}
}
预期:函数启动
结果: “Microsoft.Azure.WebJobs.Host:索引方法“Functions.Cosmostrigger”出错。Microsoft.Azure.WebJobs.Extensions.CosmosDB:无法在数据库database_name中创建collection_name的集合信息> 数据库中有租约 database_name :解析值时遇到意外字符:<.Path '',第 0 行,位置 0。Newtonsoft.Json:解析值时遇到意外字符:<.Path '' ,第 0 行,位置 0。”
最佳答案
@CosmosDBTrigger(name = "document",databaseName = "db1",collectionName = "col1",connectionStringSetting = "dbstr",leaseCollectionName = "lease1",createLeaseCollectionIfNotExists = true) 字符串文档,
现在,当您发布时,将 dbstr 的值作为连接字符串放入 Azure 门户的应用程序设置中,设置属性后只需重新启动
关于java - 如何使用java配置@CosmosDBtrigger?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57633009/