Developing the Azure Function – queue trigger

Perform the following steps:

  1. Create a new Azure Function named ProcessData using the queue trigger and configure the myqueuemessages queue. This is how the Integrate tab should look after you create the function:
  1. Replace the default code with the following code:
        using System;
public static void Run(string myQueueItem,
ILogger log)
{
if(Convert.ToInt32(myQueueItem)>50)
{
throw new Exception(myQueueItem);
}
else
{
log.LogInformation($"C# Queue trigger function
processed: {myQueueItem}");
}
}

The preceding queue trigger logs a message with the content of the queue (it's just a numerical index) for the first 50 messages and then throws an exception for the all the messages whose content is greater than 50.