I have 2 projects in Visual studio, a web API and an Azure functions project with an Azure Queue Storage trigger function. I'm using the Azure Storage Emulator. Both are usingUseDevelopmentStorage=true for the connection string. The queue client is receiving a 201 and I see the message in the storage emulator. But the trigger function is never fired. I'm not seeing any console errors. However if I add a message using the storage emulator, the trigger gets fired. So the trigger function does work, but only through the emulator. And the QueueClient code is working, I am getting a 201 and seeing the message in the emulator. I am doing this all locally, I haven't created a Queue in Azure. I don't see how that could be an issue, but I thought I would add that.
My Queue Client Code is
public async Task InsertCustomer()
{
var queueClient = new QueueClient(_configuration["StorageConnectionString"], "customer-items");
var myString = "Testing";
byte[] bytes = Encoding.Default.GetBytes(myString);
myString = Encoding.UTF8.GetString(bytes);
await queueClient.CreateIfNotExistsAsync();
//just here for debugging
var result = await queueClient.SendMessageAsync(myString);
}
The URI is is sending it to is http://127.0.0.1:10001/devstoreaccount1/customer-items
The Queue trigger is
public static class InsertCustomerQueue
{
[FunctionName("InsertCustomer")]
public static void Run([QueueTrigger("customer-items", Connection = "AzureWebJobsStorage")] string myQueueItem, ILogger log)
{
try
{
log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
}
catch (Exception ex)
{
log.LogInformation(ex.ToString());
}
}
}
}
I'm running both visual studio (2019 community) and the emulator as admin. This seems like a no-brainer, but I can't figure it out.
{}
above the edit box. You should edit your question to make these changes – Caius Jardlog
variable was null, the code would crash for every item; this would eventually cause the message to be deemed poisonous and be transferred to the xxx-poison queue. Try making sure the code cannot fail; put an empty catch block – Caius Jard