Implement Azure Storage Blobs and Azure Files
Implement Storage Tables
Implement Azure Storage Queues
Implement SQL Databases
This course teaches you how to work with Azure Storage and its associated services.
By the end of this course, you'll have gained a firm understanding of the key components that comprise the Azure Storage platform. Ideally, you will achieve the following learning objectives:
- How to comprehend the various components of Azure storage services.
- How to implement and configure Azure storage services.
- How to manage access and monitor your implementation.
This course is intended for individuals who wish to pursue the Azure 70-532 certification.
You should have work experience with Azure and general cloud computing knowledge.
This Course Includes
- 1 hour and 17 minutes of high-definition video.
- Expert-led instruction and exploration of important concepts surrounding Azure storage services.
What You Will Learn
- An introduction to Azure storage services.
- How to implement Azure storage blobs and Azure files.
- How to implement storage tables.
- How to implement storage queues.
- How to manage access and monitor storage.
- How to implement SQL databases.
Hello, and welcome back. We will now cover developing queues in Azure. We'll first cover how SDKs for queues support adding and processing messages in queues. We will then describe how processing can be done in batches. Finally, we will describe how scaling is supported.
Setting up to develop queues is very similar to working with blobs and tables. You need to provide the same connection string for the storage account and the conflict file and reference the same packages. For queue-specific functionality, you need to reference the Microsoft Windows Azure Storage Queue namespace. You don't need to create a CloudQueueClient in your code which will give you access to all the functionality for working with queues and messages.
Processing messages is relatively straight forward, as there is a limited set of operations you can perform on a queue. You can add messages using the AddMessage method, you can get messages from the queue using GetMessages. You can use this method to de-queue multiple messages and process these in a batch.
On the topic of scaling, queues can typically process about 2,000 messages per second, however you can use multiple queues to increase throughput if required. You can retrieve up to 32 messages from a queue in a single operation. This can reduce the number of retrieval requests the client application has to make and the number of operations against the queue, and can therefore improve performance. To improve performance, you can spread queue processing across multiple servers. For this purpose, Azure includes auto-scaling functionality to scale the number of VMs, or cloud service instances depending on the size of the queue.
In this demo, we'll cover developing queues, including creating queues, adding messages, and de-queuing a single message or a batch of messages. I'm here in Visual Studio, and in this example, we'll look at a basic queue operation, the creation of the queue itself. As usual, we will firstly require a connection stream for our storage account. We'll also be importing the Microsoft.WindowsAzure.Storage.Queue namespace that contains the classes and utilities for dealing with Azure queues. Again, the same pattern as blobs and tables, we create a queue reference and call the common creative not exists method to create the queue.
First of all, we have no queues, if we look in the cloud explorer here, there is nothing there. If we now run this, and now that's finished. Refresh. Now we have the queue directors. Inserting a message is equally straight forward. We'll first need to create a new message, which requires us to create a new instance of the cloud queue message type. Take special note of this class, as it's a focal point of the certification path and it's often featured in practice test materials. Having created our message, we can now go ahead and call AddMessage on the queue object, passing in the message as our only argument. If we run this now, and inspect the queue, we should see an entry in the queue, so let's run this and give it a try. And now as you can see, we have our message in the queue.
Let's now have a look at retrieving a message from the queue starting with our queue reference, we call GetMessage. After calling GetMessage, the message becomes invisible in the queue to other processes, but only for 30 seconds. Our client now needs to call DeleteMessage within 30 seconds, or the message will be reinstated on the queue, by being made visible again. We therefore have 30 seconds in which to process the message or alternatively call DeleteMessage immediately and deal with any message processing errors ourself. This is a key point when developing Azure queue consumers.
Retrieving multiple messages is very similar to retrieving a single message with a couple of differences. We call GetMessages, passing in an argument for the number of messages we want up to 32. We can also alternately provide a time out argument, telling the queue how long the messages should remain invisible to other clients. We may need to specify this if the default is not enough time for us to process the number of messages that we're requesting. If there are fewer messages on the queue than the number requested, our client will receive all the messages on the queue. Again, we need to call DeleteMessage on any message we don't want reappearing in the queue. In our example, we'll loop over the messages, calling DeleteMessage on each one.
Stay tuned for the next section, where we'll look closer at access control in Azure.
Isaac has been using Microsoft Azure for several years now, working across the various aspects of the service for a variety of customers and systems. He’s a Microsoft MVP and a Microsoft Azure Insider, as well as a proponent of functional programming, in particular F#. As a software developer by trade, he’s a big fan of platform services that allow developers to focus on delivering business value.