带有 Cosmos DB 输入的 Azure Function HttpTrigger
Azure Function HttpTrigger with Cosmos DB input
我正在尝试创建一个带有 cosmos DB 输入绑定的 Azure Function HttpTrigger。
但它给我一个类型错误。
这是我正在尝试的:
public static async Task<IActionResult> Run(IReadOnlyList<Document> inputDocs, HttpRequest req, IAsyncCollector<Document> outputDocs, ILogger log)
{
}
它给我以下错误:
2019-06-03T06:48:35.646 [Error] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.HttpTrigger1'. Microsoft.Azure.WebJobs.Host: Can't bind CosmosDB to type 'System.Collections.Generic.IReadOnlyList`1[Microsoft.Azure.Documents.Document]'.
Possible causes:
1) Tried binding to 'Microsoft.Azure.Documents.Client.DocumentClient, Microsoft.Azure.DocumentDB.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' but user type assembly was 'System.Collections.Generic.IReadOnlyList`1[[Microsoft.Azure.Documents.Document, Microsoft.Azure.DocumentDB.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e.
2) Tried binding to 'Newtonsoft.Json.Linq.JArray, Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' but user type assembly was 'System.Collections.Generic.IReadOnlyList`1[[Microsoft.Azure.Documents.Document, Microsoft.Azure.DocumentDB.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e.
3) Tried binding to 'System.Collections.Generic.IEnumerable`1[[Microsoft.Azure.WebJobs.Extensions.CosmosDB.CosmosDBExtensionConfigProvider+DocumentOpenType, Microsoft.Azure.WebJobs.Extensions.CosmosDB, Version=3.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' but user type assembly was 'System.Collections.Generic.IReadOnlyList`1[[Microsoft.Azure.Documents.Document, Microsoft.Azure.DocumentDB.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e.
谁能帮我打字?
查看此处的示例,这与您正在做的差不多:https://docs.microsoft.com/en-us/sandbox/functions-recipes/cosmos-db?tabs=csharp#retrieve-a-list-of-documents
[FunctionName("CosmosDBSample")]
public static HttpResponseMessage Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequestMessage req,
[DocumentDB("test", "test", ConnectionStringSetting = "CosmosDB", sqlQuery = "SELECT top 2 * FROM c order by c._ts desc")] IEnumerable<object> documents)
{
return req.CreateResponse(HttpStatusCode.OK, documents);
}
我正在尝试创建一个带有 cosmos DB 输入绑定的 Azure Function HttpTrigger。 但它给我一个类型错误。
这是我正在尝试的:
public static async Task<IActionResult> Run(IReadOnlyList<Document> inputDocs, HttpRequest req, IAsyncCollector<Document> outputDocs, ILogger log)
{
}
它给我以下错误:
2019-06-03T06:48:35.646 [Error] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.HttpTrigger1'. Microsoft.Azure.WebJobs.Host: Can't bind CosmosDB to type 'System.Collections.Generic.IReadOnlyList`1[Microsoft.Azure.Documents.Document]'.
Possible causes:
1) Tried binding to 'Microsoft.Azure.Documents.Client.DocumentClient, Microsoft.Azure.DocumentDB.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' but user type assembly was 'System.Collections.Generic.IReadOnlyList`1[[Microsoft.Azure.Documents.Document, Microsoft.Azure.DocumentDB.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e.
2) Tried binding to 'Newtonsoft.Json.Linq.JArray, Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' but user type assembly was 'System.Collections.Generic.IReadOnlyList`1[[Microsoft.Azure.Documents.Document, Microsoft.Azure.DocumentDB.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e.
3) Tried binding to 'System.Collections.Generic.IEnumerable`1[[Microsoft.Azure.WebJobs.Extensions.CosmosDB.CosmosDBExtensionConfigProvider+DocumentOpenType, Microsoft.Azure.WebJobs.Extensions.CosmosDB, Version=3.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' but user type assembly was 'System.Collections.Generic.IReadOnlyList`1[[Microsoft.Azure.Documents.Document, Microsoft.Azure.DocumentDB.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e.
谁能帮我打字?
查看此处的示例,这与您正在做的差不多:https://docs.microsoft.com/en-us/sandbox/functions-recipes/cosmos-db?tabs=csharp#retrieve-a-list-of-documents
[FunctionName("CosmosDBSample")]
public static HttpResponseMessage Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequestMessage req,
[DocumentDB("test", "test", ConnectionStringSetting = "CosmosDB", sqlQuery = "SELECT top 2 * FROM c order by c._ts desc")] IEnumerable<object> documents)
{
return req.CreateResponse(HttpStatusCode.OK, documents);
}