Azure函数documentdb出参数错误
Azure function documentdb out parameters error
如何将 docuementdb 绑定与 azure 函数 http 绑定结合使用:
using System.Net;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, out object locationDocument, TraceWriter log){
log.Info("C# HTTP trigger function processed a request.");
var data = await req.Content.ReadAsStringAsync();
return req.CreateResponse(HttpStatusCode.OK, $"{data}");
}
出现此错误:
error CS1988: Async methods cannot have ref or out parameters
这并非特定于文档数据库。如果您的函数是异步的,并且您已经为 HTTP 输出绑定使用了 return 值,则您需要为所有其他输出绑定注入 IAsyncCollector<T>
。
见第二个例子。
如何将 docuementdb 绑定与 azure 函数 http 绑定结合使用:
using System.Net;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, out object locationDocument, TraceWriter log){
log.Info("C# HTTP trigger function processed a request.");
var data = await req.Content.ReadAsStringAsync();
return req.CreateResponse(HttpStatusCode.OK, $"{data}");
}
出现此错误:
error CS1988: Async methods cannot have ref or out parameters
这并非特定于文档数据库。如果您的函数是异步的,并且您已经为 HTTP 输出绑定使用了 return 值,则您需要为所有其他输出绑定注入 IAsyncCollector<T>
。
见第二个例子