Frank
Frank

Reputation: 13

Azure Queue Storage visual studio local host all queue messages sent from QueueClient going to poison queue

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.

Upvotes: 1

Views: 843

Answers (1)

Frank
Frank

Reputation: 13

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.

Upvotes: 0

Related Questions