When creating a new QueueTrigger Azure function, I'd like to switch the string input to a CloudQueueMessage.
I have changed the signature to:
public async static Task Run([QueueTrigger("%queue-name%", Connection = "AzureStorageConnection")]CloudQueueMessage myQueueItem, TraceWriter log)
I get the error below:
8/15/17 12:16:07 AM] Function started (Id=a137d868-1256-4a67-a225-8a95fb0e31fb)
[8/15/17 12:16:07 AM] Executing 'TokenRefresh' (Reason='New queue message detected on 'refreshtoken'.', Id=a137d868-1256-4a67-a225-8a95fb0e31fb)
[8/15/17 12:16:07 AM] A ScriptHost error has occurred
[8/15/17 12:16:07 AM] Exception while executing function: TokenRefresh. Microsoft.Azure.WebJobs.Host: Exception binding parameter 'myQueueItem'. mscorlib: String reference not set to an instance of a String.
[8/15/17 12:16:07 AM] Parameter name: s.
The function app is correctly popping items and then then because it is then throwing rapid exceptions all items in that queue go to the poison queue. I'm using the latest functions sdk and windows azure sdk nuget packages.
According to your description, I checked this issue on Azure portal. I found it could work, and here is the code snippet under my run.csx file as follows:
#r "Microsoft.WindowsAzure.Storage"
using System;
using Microsoft.WindowsAzure.Storage.Queue;
[FunctionName("QueueTriggerCSharp")]
public static void Run([QueueTrigger("myqueue-items", Connection = "AzureWebJobsStorage")]CloudQueueMessage myQueueItem, TraceWriter log)
{
log.Info($"C# Queue trigger function processed: {myQueueItem.AsString}");
}
Result:
2017-08-15T07:35:27.104 Function started (Id=0ed03b74-bc9c-408a-9607-55e2942f1d50)
2017-08-15T07:35:27.214 C# Queue trigger function processed: sample queue data
2017-08-15T07:35:27.214 Function completed (Success, Id=0ed03b74-bc9c-408a-9607-55e2942f1d50, Duration=108ms)
As garth mason mentioned, then I checked it on my local side by using VS 2017 function class library. Also, I found a similar issue How to change the parameters types using a queue trigger and a VS 2017 function class library and this git issue, you could refer to them for solving this issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With