1

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 Answer 1

2

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();
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the detailed solution! Never know the simple string is different from the base64 encoded string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.