0
votes

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.

1
To post code or format a block of your post as mono space/preformatted, prefix every line with 4+ spaces or start and end the code block with 3 back ticks ``` on their own line. The simplest way is to highlight the code and click {} above the edit box. You should edit your question to make these changesCaius Jard
Messages go on a poison queue if an exception occurs during their processing. If for example your log 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 blockCaius Jard
Sorry about that, it looked formatted in the editor. It seems I needed a blank line before the code blocksFrank

1 Answers

0
votes

Thanks all, Now I see it. I thought the string needed to be UTF-8, but it turns out it needed to be base64 encoded.