Azure

Be taught About Microsoft Azure – Queue

Introduction 

 

On this article, you’ll find out about queues in Microsoft Azure and how one can handle queues utilizing Powershell. 

 

On this planet of computer systems and knowledge buildings, the queue is a group of entities. This assortment is maintained in a sequence, this sequence might be modified by including entities on one finish and eradicating them from the opposite. The sequence the place the weather are added is known as again, tail, or rear of the queue. Head or entrance of the queue is known as to the purpose from the place components are eliminated.

 

What’s Queue in a layman’s language?

 

From a perspective of a developer, the queue is mainly a knowledge construction used to retailer knowledge in a way that follows the First-in First-out rule. Knowledge might be added to the tail whereas it’s deleted from the entrance. The method of including to the rear is known as enqueue, and eradicating from the entrance is known as dequeue.

 

Queue And Microsoft Azure

 

Azure queues use an identical idea to retailer messages in a queue. The method adopted by Azure in message queue service is,

  1. Firstly, a sender sends the message which is acquired by the consumer and processes them. This message may need some attributes hooked up to it.
  2. As soon as the consumer has processed the message it deletes it. What Azure does is its service retailer the message for 7 days and deletes it routinely after it if it’s not accomplished by the consumer.

Generally, there’s one sender and one consumer or one sender and many consumers. Many senders and many consumers are additionally one of many eventualities.

 

Decoupling the segments is without doubt one of the advantages of message queue providers. It runs in an offbeat local weather the place messages might be despatched among the many varied elements of an software. On this method, it offers a productive reply for overseeing work processes and undertakings. For example, a message to complete an endeavor is distributed from the frontend of the appliance and is gotten by a backend laborer, who at that time finishes the task and erases the message.

 

Notice

The Message doesn’t duplicate anyplace. Because of this there just one copy of your message. The utmost variety of messages is 20,000 whereas the dimensions restrict is 64kb.

 

Tips on how to Handle Queues utilizing PowerShell?

 

Create a Queue

 

Step 1

 

Proper-click on Home windows PowerShell within the taskbar. Select ‘Run ISE as administrator’.

 

Step 2

 

Run the next command to entry your account. Please exchange the highlighted half in your account.

  1. $context = New-AzureStorageContext -StorageAccountName csharpcorner StorageAccountKey ****************   

Step 3

 

Specify the storage account during which you need to create a queue.

  1. Set-AzureSubscription –SubscriptionName “csharp” -CurrentStorageAccount csharpcorner   

Step 4

 

Create a Queue.

  1. $QueueName = “queue” $Queue = New-AzureStorageQueue –Identify $QueueName -Context $Ctx   

Retrieve a Queue

  1. $QueueName = “queue” $Queue = Get-AzureStorageQueue –Identify $QueueName –Context $Ctx  

Delete a Queue

  1. $QueueName = “queue” Take away-AzureStorageQueue –Identify $QueueName –Context $Ctx   

Insert a Message right into a Queue

 

Step 1 

 

Login to your account.

  1. $context = New-AzureStorageContext -StorageAccountName csharpcorner StorageAccountKey *************   

Step 2

 

Specify the storage account you need to use.

  1. Set-AzureSubscription –SubscriptionName “csharp” -CurrentStorageAccount csharpcorner   

Step 3 

 

Retrieve the queue after which insert the message.

  1. $QueueName = “myqueue”  
  2. $Queue = Get – AzureStorageQueue – Identify $QueueName – Context $ctx  
  3. if ($Queue – ne $null) {  
  4.     $QueueMessage = New – Object – TypeName Microsoft.WindowsAzure.Storage.Queue.CloudQueueMessage – ArgumentList “this is my message”  
  5.     $Queue.CloudQueue.AddMessage($QueueMessage)  
  6. }   

The ‘if’ situation within the script above checks if the queue specified exists or not.

 

Dequeue Subsequent Message from Queue

 

Step 1

 

Join the account and specify the storage account, by working the instructions as proven within the above steps.

 

Step 2 

 

Retrieve the queue.

  1. $QueueName = “myqueue” $Queue = Get-AzureStorageQueue -Identify $QueueName -Context $ctx $InvisibleTimeout = [System.TimeSpan]::FromSeconds(10)  

Step 3 

 

Dequeue the following message.

  1. $QueueMessage = $Queue.CloudQueue.GetMessage($InvisibleTimeout)   

Step 4 

 

Delete the dequeued message.

  1. $Queue.CloudQueue.DeleteMessage($QueueMessage)   

Managing Queues utilizing Azure Storage Explorer

  1. From the drop-down menu from the highest proper choose the storage account. Account will probably be displayed that had been added earlier than. If not, you may add an account and proceed utilizing Azure Storage Explorer.
  2. Add queue by deciding on ‘Queues’ from the left panel and faucet on new.
  3. Enter the title.
  4. Add and delete the messages from deciding on the queue within the left panel.

Abstract

 

On this article, we mentioned azure queues and how one can retrieve, delete, Azure queues. Any solutions or suggestions or question associated to this text are most welcome.

    Show More

    Related Articles

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Back to top button