- Microsoft Azure - Scenarios
- Microsoft Azure - Datacenters
- Microsoft Azure - Security
- Microsoft Azure - Applications
- Microsoft Azure - CDN
- Microsoft Azure - Tables
- Microsoft Azure - Queues
- Microsoft Azure - Blobs
- Microsoft Azure - Storage
- Microsoft Azure - Fabric Controller
- Microsoft Azure - Compute Module
- Microsoft Azure - Components
- Microsoft Azure - Windows
- Cloud Computing - Overview
- Microsoft Azure - Home
Microsoft Azure Advanced
- Microsoft Azure - Upgrades
- Microsoft Azure - Health Monitoring
- Azure - Orchestrated Recovery
- Azure - Security Reports & Alerts
- Microsoft Azure - Create a Group
- Microsoft Azure - Self-Service Group
- Azure - Self-Service Password Reset
- Azure - Personalize Company Brand
- Microsoft Azure - Personalize Access
- Microsoft Azure - Disk Caching
- Microsoft Azure - Disk Configuration
- Microsoft Azure - Scalability
- Microsoft Azure - Websites
- Azure - Data Import & Export Job
- Azure - Forefront Identity Manager
- Azure - Multi-Factor Authentication
- Azure - Self-Service Capabilities
- Microsoft Azure - Backup & Recovery
- Azure - Application Deployment
- Azure - Setting Up Alert Rules
- Azure - Monitoring Virtual Machines
- Microsoft Azure - PowerShell
- Microsoft Azure - Traffic Manager
- Azure - Site-to-Site Connectivity
- Azure - Point-to-Site Connectivity
- Azure - Endpoint Configuration
- Azure - Deploying Virtual Machines
- Azure - Create Virtual Network
- Microsoft Azure - Management Portal
Microsoft Azure Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Microsoft Azure - Queues
In the common language used by developers, a queue is a data structure used to store data which follows First in-First out rule. A data item can be inserted from back of the queue while it is retrieved from front. Azure queues are a very similar concept that is used to store the messages in a queue. A sender sends the message and a cpent receives and processes them. A message has few attributes attached to it, for example expiry time.
A cpent usually processes and deletes the message. Windows Azure service lets the message to be stored for 7 days and later it gets deleted automatically, if it is not deleted by the cpent. There can be one sender and one cpent or one sender and many cpents or many sender and many cpents.
There are two services offered by Windows Azure for message queues. This chapter covers Windows Azure queue. The other service is called ‘Service Bus queue’.
Decouppng the components is one of the advantages of message queue services. It runs in an asynchronous environment where messages can be sent among the different components of an apppcation. Thus, it provides an efficient solution for managing workflows and tasks. For example, a message to complete a task is sent from the frontend of the apppcation and is received by a backend worker, who then completes the task and deletes the message.
Considerations
The messages in the storage queue are not reppcated anywhere, that means there is only one copy of your message. The maximum number of messages that can be processed are 20,000. The maximum size of a message can be 64 kb.
Managing Queues using PowerShell
Create a Queue
Step 1 − Right-cpck on Windows PowerShell in the taskbar. Choose ‘Run ISE as administrator’.
Step 2 − Run the following command to access your account. Please replace the highpghted part for your account.
$context = New-AzureStorageContext -StorageAccountName tutorialspoint StorageAccountKey iUZNeeJD+ChFHt9XHL6D5rkKFWjzyW4FhV0iLyvweDi+Xtzfy76juPzJ+mWtDmbqCWjsu/nr+1pqBJj rdOO2+A==
Step 3 − Specify the storage account in which you want to create a queue.
Set-AzureSubscription –SubscriptionName "BizSpark" -CurrentStorageAccount tutorialspoint
Step 4 − Create a Queue.
$QueueName = "thisisaqueue" $Queue = New-AzureStorageQueue –Name $QueueName -Context $Ctx
Retrieve a Queue
$QueueName = "thisisaqueue" $Queue = Get-AzureStorageQueue –Name $QueueName –Context $Ctx
Delete a Queue
$QueueName = "thisisaqueue" Remove-AzureStorageQueue –Name $QueueName –Context $Ctx
Insert a Message into a Queue
Step 1 − Login to your account.
$context = New-AzureStorageContext -StorageAccountName tutorialspoint StorageAccountKey iUZNeeJD+ChFHt9XHL6D5rkKFWjzyW4FhV0iLyvweDi+Xtzfy76juPzJ+mWtDmbqCWjsu/nr+1pqBJj rdOO2+A==
Step 2 − Specify the storage account you want to use.
Set-AzureSubscription –SubscriptionName "BizSpark" -CurrentStorageAccount tutorialspoint
Step 3 − Retrieve the queue and then insert the message.
$QueueName = "myqueue" $Queue = Get-AzureStorageQueue -Name $QueueName -Context $ctx if ($Queue -ne $null) { $QueueMessage = New-Object -TypeName Microsoft.WindowsAzure.Storage.Queue.CloudQueueMessage -ArgumentList "my message is this" $Queue.CloudQueue.AddMessage($QueueMessage) }
The ‘if’ condition in the script above checks if the queue specified exists or not.
Dequeue Next Message from Queue
Step 1 − First connect to your account and specify the storage account, by running the commands as shown in the above steps.
Step 2 − Retrieve the queue.
$QueueName = "myqueue" $Queue = Get-AzureStorageQueue -Name $QueueName -Context $ctx $InvisibleTimeout = [System.TimeSpan]::FromSeconds(10)
Step 3 − Dequeue the next message.
$QueueMessage = $Queue.CloudQueue.GetMessage($InvisibleTimeout)
Step 4 − Delete the dequeued message.
$Queue.CloudQueue.DeleteMessage($QueueMessage)
Managing Queues using Azure Storage Explorer
Step 1 − Select the storage account from the dropdown at the top right. Accounts will be displayed if you have added them during your previous use. If not, you can add account and it will ask for your credentials. After signing in, you will be logged into your account in Azure Storage Explorer.
Step 2 − You can add a new queue by selecting ‘Queues’ from the left panel and cpcking ‘New’ as shown in the following image.
Step 3 − Enter the name of Queue and it is created in your storage account.
Step 4 − Add and delete the messages by selecting the queue in the left panel.
Advertisements