Alvin
Alvin

Reputation: 8499

Azure function documentdb out parameters error

How do I use docuementdb binding with azure function http binding:

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}");
}

Getting this error:

error CS1988: Async methods cannot have ref or out parameters

Upvotes: 0

Views: 396

Answers (1)

Mikhail Shilkov
Mikhail Shilkov

Reputation: 35134

This is not specific to Document DB. If your function is async, and you already used the return value for HTTP output binding, you would need to inject IAsyncCollector<T> for all other output bindings.

See the second example in this answer.

Upvotes: 1

Related Questions