Reputation: 379
I published my 3 different versions of a function and the last one is where things start to go wrong. I think it's the combination of async, queue trigger and a return value, but I don't know for sure (and I can't find any documentation that helps me out).
V1: Out-of-box Visual Studio template
[FunctionName("Function1")]
public static void Run([QueueTrigger("myqueue-items", Connection = "")]string myQueueItem, TraceWriter log)
{
log.Info($"C# Queue trigger function processed: {myQueueItem}");
}
Works as expected when I deploy & test.
V2: Change to async Task
[FunctionName("Function1")]
public static async Task([QueueTrigger("myqueue-items", Connection = "")]string myQueueItem, TraceWriter log)
{
await Task.Delay(1000);
log.Info($"C# Queue trigger function processed: {myQueueItem}");
}
Still good.
V3: Use Task<string>
[FunctionName("Function1")]
public static async Task<string> Run([QueueTrigger("myqueue-items", Connection = "")]string myQueueItem, TraceWriter log)
{
await Task.Delay(1000);
log.Info($"C# Queue trigger function processed: {myQueueItem}");
return new string(myQueueItem.Reverse().ToArray());
}
}
Now when I test in the portal all I see is Status: 202 Accepted
, no output, nothing logged, no error in log streaming, etc. Practically impossible to figure out what's going wrong other than this incremental guess-and-check that I did.
Any ideas what the issue is?
Upvotes: 2
Views: 1160
Reputation: 35154
Queue trigger can't return any data to the caller: it's a queue after all.
You could use Output Binding feature, for instance to send the output to another queue. But then you need to annotate this binding with an extra attribute:
[FunctionName("Function1")]
[return: Queue("myqueue-output", Connection = "")]
public static async Task<string> Run([QueueTrigger("myqueue-items", Connection = "")]string myQueueItem, TraceWriter log)
{
await Task.Delay(1000);
log.Info($"C# Queue trigger function processed: {myQueueItem}");
return new string(myQueueItem.Reverse().ToArray());
}
Upvotes: 4