How to Insert Message from visual studio C# to Queue in Azure?

Asked

Viewed 31 times

-1

To insert message in the I ran this code that seems to be correct and however, it still doesn’t work I don’t know why the error it gives (in the addmessage part is 404 not found and from what I saw on the net the connections seem to be well done.

What’s green was another attempt to do the same thing another way.

What may be causing this error and how can I fix it?

codigo

  • 1

    Instead of posting the image, post the code because it makes it easier for anyone to help you. Use the option {} to format the code. Do a [tour].

1 answer

0

To insert a message in an existing queue, first create a new Cloudqueuemessage. Then call the Addmessage method. A Cloudqueuemessage can be created using a string (in UTF-8 format) or a byte array. This is the code that creates a queue (if it does not exist) and inserts the message 'Hello, World':

// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
    CloudConfigurationManager.GetSetting("StorageConnectionString"));

// Create the queue client.
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();

// Retrieve a reference to a queue.
CloudQueue queue = queueClient.GetQueueReference("myqueue");

// Create the queue if it doesn't already exist.
queue.CreateIfNotExists();

// Create a message and add it to the queue.
CloudQueueMessage message = new CloudQueueMessage("Hello, World");
queue.AddMessage(message);

Source: Introduction to Azure Message Queue > How to insert a message in the queue

Browser other questions tagged

You are not signed in. Login or sign up in order to post.