Azure-functions-host: Support IAsyncCollector in Node output bindings

Created on 2 Apr 2016  路  6Comments  路  Source: Azure/azure-functions-host

We currently only allow you to output a single item (e.g. queue message). We need to support an array of items. This will apply to all binding types that support ICollector (Qeueus, ServiceBus, Tables, etc.).

See SO post here: https://stackoverflow.com/questions/36374464/can-i-queue-multiple-items-from-a-single-run-of-an-azure-function

Can't get ICollector working for C# either. I expected the following to work but it didn't:

public static HttpResponseMessage Run(HttpRequestMessage req, ICollector<string> messageQueue, TraceWriter log)
{
    log.Verbose($"C# HTTP trigger function processed a request. RequestUri={req.RequestUri}");

    string[] messages = new [] { "Larry", "Moe", "Curly" };
    foreach (var message in messages)
    {
        messageQueue.Add(message);
    }

    return req.CreateResponse(HttpStatusCode.OK);
}
high-pri

Most helpful comment

Thanks for the eagerness :) The plan is @davidebbo will deploy it tomorrow morning. I tested it out and it works great :) Here's an example from our samples, showing how it works.

All 6 comments

I've got this working for the Queue binding. Will centralize the code so it is shared across all the other bindings that need to support collection output (Queue, ServiceBus, Table, DocDB, etc.)

I'm eagerly waiting this, is it deployed? :)

Thanks for the eagerness :) The plan is @davidebbo will deploy it tomorrow morning. I tested it out and it works great :) Here's an example from our samples, showing how it works.

@TheBlueSky It is now deployed!

Thanks @mathewc and @davidebbo... and I'm glad to report that my first test shows that it works :)

:smile:

Was this page helpful?
0 / 5 - 0 ratings