1
votes

I have successfully sent some messages to Azure queue storage.

Here's a code of how I send messages to my queue storage:

private void QueueEmail(Email email)
{
    QueueClient client = GetQueueStorage("invoice-email");

    var message = JsonConvert.SerializeObject(email);

    System.Diagnostics.Debug.WriteLine(message);
    client.SendMessageAsync(message).Wait();
}

Queue Storage

The errors occur when I try to run the azure function to process the queue, the execution failed. Below are the error messages. Error me

Does anyone know how to solve this problem?

1

1 Answers

1
votes

The reason you're running into this issue is because Function is expecting a base64 encoded string and you're passing a simple string.

From this link:

Encoding

Functions expect a base64 encoded string. Any adjustments to the encoding type (in order to prepare data as a base64 encoded string) need to be implemented in the calling service.

Before sending the message, please try to convert that to a base64 encoded string. Something like:

private void QueueEmail(Email email)
{
    QueueClient client = GetQueueStorage("invoice-email");

    var message = JsonConvert.SerializeObject(email);

    System.Diagnostics.Debug.WriteLine(message);
    client.SendMessageAsync(Convert.ToBase64String(Encoding.UTF8.GetBytes(message))).Wait();
}