How to create queue in Azure?

How to create queue in Azure?

How to create queue in Azure?

Queues:

Azure Queues are queues located in Microsoft cloud which can be used for exchanging messages between components eighther in the cloud or on premise.

The queue depicts FIFO behavior.

Windows Azure queues storage is a service for storing a large number of messages that can be accessed anywhere in the world via authenticated calls using HTTP or HTTPS.

A single queue message can be upto 64 kb in size, a queue can contain upto the 100 TB total capacity limit of the storage account.

Limitations:

1.       The Queue service supports an unlimited number of messages, but individual messages in the queue service can’t be more than 8KB in size.

2.       The FIFO behavior of the messages sent to the Queue Service isn’t guaranteed.

3.       Messages can be received in any order.

4.       The Queue Service doesn’t offer guaranteed once delivery.This means a message may be received more than once.

5.       Messages sent to the queue service can be eighther text or binary format, but received messages are always in Base 64 encoded Format.

6.       The expiration time of the messages stored in the queue is & days, after seven days the messages are garbage collected.

 

Pre-requirements:

1.       Storage -Account

OBJECTIVE:

1.       Queue in a storage account and store data in that queue

Code:

// Retrieve storage account from the 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);


Comments