2

I want to use output queue in my azure function. I get an example code from: https://learn.microsoft.com/en-us/sandbox/functions-recipes/queue-storage

[FunctionName("BasicQueueOutput")]
public static void Run([TimerTrigger("*/30 * * * * *")]TimerInfo myTimer,
                       TraceWriter log,
                       [Queue("101functionsqueue",Connection = "AzureWebJobsStorage")] out string queueMessage)
{
    log.Info("101 Azure Function Demo - Storage Queue output");

    queueMessage = DateTime.UtcNow.ToString();
}

it works fine for sync method, but in my case it's async method:

    [FunctionName("FunctionRegisterDomain")]
    public async static Task Run(
        [QueueTrigger("domain-registation", Connection = "StorageConnectionString")]DomainForRegistration queueItem,
        [Queue("domain-add-to-office365", Connection = "StorageConnectionString")]out DomainForRegistration outputQueue,
        ILogger log)

and I get an error:

Async methods cannot have ref, in or out parameters

of course, I can do it :

    [Queue("domain-add-to-office365", Connection = "StorageConnectionString")]CloudQueue outputQueue,

and then use it:

await outputQueue.AddMessageAsync(new CloudQueueMessage(JsonConvert.SerializeObject(queueItem)));

but I would like to do it with bindings to queue message

1 Answer 1

4

You are looking for IAsyncCollector<T> to change from out param to that. Instead of “out string message” you change to ICollector<string> messages or IAsyncCollector<string> and add you message to the collection in the body.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.