Azure函数documentdb输出参数错误

时间:2017-03-07 02:27:40

标签: azure azure-cosmosdb azure-functions

如何使用docurementdb绑定与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

1 个答案:

答案 0 :(得分:1)

这不是Document DB特有的。如果您的函数是异步的,并且您已经使用HTTP输出绑定的返回值,则需要为所有其他输出绑定注入IAsyncCollector<T>

请参阅第二个示例in this answer