3

I have an azure queue trigger set up:

    [FunctionName("TransformData")]
    public async Task Transform(
        [QueueTrigger("product-prices")] string message)
    {
        await TransformAndLoadData(message);
    }

Whenever I add items to the queue via the QueueClient:
(RawQueueData splits items into message batches)

    var rawQueueData = new RawQueueData<T>(data);

    var sendMessageTasks = rawQueueData.Messages
        .Select(m => _queueClient.SendMessageAsync(m));
    
    await Task.WhenAll(sendMessageTasks);

Or move the messages from product-prices-poison back to product-prices queue (using Azure Storage Explorer), the trigger immediately fails with:

Message has reached MaxDequeueCount of 5. Moving message to queue product-prices-poison.

Passing items synchronously also yields the same problem.

The only time I can successfully get the trigger to fire and process items is when I create a message with Azure Storage Explorer manually.

Increasing MaxDequeueCount, or batch size does not make a difference. The message after doing the former then is:

Message has reached MaxDequeueCount of 100000. Moving message to queue product-prices-poison.

I can also manually dequeue items by using the QueueClient without any issues.


I have also tried changing the type of object I am receiving to QueueMessage, object and string. Most other solutions seem to focus on updating the package (the one I am using the latest - stable 12.8.0).

EDIT: host.json:

{
  "version": "2.0",
  "extensions": {
    "blobs": {
      "maxDegreeOfParallelism": "4"
    },
    "queues": {
      "maxDequeueCount": 5
    }
  }
}
Lukas
  • 162
  • 9

1 Answers1

8

Thank you for being my rubber duck.

After writing I soon realized the only different thing between azure storage explorer's "New Message" was the encoding.

After switching the messages encoding to Base64 it started working.

Lukas
  • 162
  • 9
  • For reference, this started happening with a new version of the client library (see https://github.com/Azure/azure-sdk-for-net/issues/10242). Whilst I'm at it, in case anyone finds it useful, here's a good answer on how to Base64 encode a string: https://stackoverflow.com/a/11743162/50151 – Tom Wright Jul 29 '22 at 11:57