在预编译的C#Azure函数中使用命令绑定时,如何定义Cosmos DB数据库和集合名称?
在预编译的C#Azure函数中使用命令绑定时,如何定义Cosmos DB数据库和集合名称 我遵循了在预编译的C#Azure函数中使用命令绑定时,如何定义Cosmos DB数据库和集合名称?,c#,azure,binding,azure-cosmosdb,azure-functions,C#,Azure,Binding,Azure Cosmosdb,Azure Functions,在预编译的C#Azure函数中使用命令绑定时,如何定义Cosmos DB数据库和集合名称 我遵循了run.csxC#脚本示例,效果很好 尝试对预编译的C#函数执行类似操作,并注意到生成的function.json缺少数据库和集合名称 已使用DocumentDB获取属性化的方法 [HttpTrigger( AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, [Docum
run.csx
C#脚本示例,效果很好
尝试对预编译的C#函数执行类似操作,并注意到生成的function.json
缺少数据库和集合名称
已使用DocumentDB
获取属性化的方法
[HttpTrigger(
AuthorizationLevel.Function,
"get", "post",
Route = null)] HttpRequestMessage req,
[DocumentDB(
ConnectionStringSetting = "cflogdev_DOCUMENTDB",
CreateIfNotExists = true,
PartitionKey = "user" )] out object logDocument,
ILogger log)
但是Intellisense没有将数据库和集合作为可设置的值,但是它确实有一个过载
我已经查过了
它将它们作为第二个构造函数的一部分
但是如何设置它们呢?DocumentDBAttribute(databaseName,collectionName)
构造函数在我使用的版本(1.1.0-beta1
)中可用。这些属性是只读的,因此您不能从默认构造函数中设置它们。DocumentDBAttribute(databaseName,collectionName)
构造函数在我使用的版本(1.1.0-beta1
)中可用。这些属性是只读的,因此无法从默认构造函数设置它们。这解决了这个问题
public static HttpResponseMessage Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req,
[DocumentDB(
"logDatabase",
"logCollection",
ConnectionStringSetting = "cflogdev_DOCUMENTDB",
//PartitionKey = "user",
CreateIfNotExists = true
)] out object logDocument,
ILogger log)
我正在使用Microsoft.Azure.WebJobs.Extensions.DocumentDB的1.0.0版,这解决了它
public static HttpResponseMessage Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req,
[DocumentDB(
"logDatabase",
"logCollection",
ConnectionStringSetting = "cflogdev_DOCUMENTDB",
//PartitionKey = "user",
CreateIfNotExists = true
)] out object logDocument,
ILogger log)
我正在使用Microsoft.Azure.WebJobs.Extensions.DocumentDB的1.0.0版