A queue is a data structure that works on a FIFO (first in first out) basis. Items are inserted at the rear of the queue and removed from the front. The term “Enqueue” denotes the operation that inserts data in the queue, while the term “Dequeue” denotes the removal of data from the queue.

Azure supports two types of queues: the Azure Storage queues and Azure Service Bus queues.

To work with the code examples, you should have Visual Studio 2019 installed in your system.

Create a console application project in Visual Studio

First off, let’s create a .NET Core console application project in Visual Studio. Assuming Visual Studio 2019 is installed in your system, follow the steps outlined below to create a new .NET Core console application project in Visual Studio.

  • Launch the Visual Studio IDE.
  • Click on “Create new project.”
  • In the “Create new project” window, select “Console App (.NET Core)” from the list of templates displayed.
    Click Next.
  • In the “Configure your new project” window shown next, specify the name and location for the new project.
  • Click Create.

What is Azure Queue Storage?

Azure Queue Storage is a Microsoft Azure cloud service that enables you to store vast numbers of messages for processing. You can take advantage of authenticated HTTP or HTTPS calls to access messages from anywhere in the globe in a secure manner. The maximum size of a queue message is 64 KB. A queue in Azure Queue Storage can store huge numbers of messages (even millions), up to a maximum storage capacity of 200 TB.

Like your other Azure Storage data objects, including blobs, files, and tables, your queues are stored in your Azure Storage account. The Azure Storage account gives you a distinct namespace for your Azure Storage data, which you can access over HTTP or HTTPS from anywhere on the world.

Install the Azure.Storage.Queues NuGet package

To work with Azure Queue Storage, you should install the Azure.Storage.Queues NuGet package into your project.

You can install this package from the NuGet package manager or by running the following command in the package manager console window.

Create an Azure Queue Storage client

If you don’t already have an Azure Storage account, you should create one using the Azure Portal or Azure PowerShell or Azure CLI. Then copy the connection string and the account access keys because you’ll need them to connect to your Azure Storage account.

Send and receive messages using Azure Queue Storage

The following code snippet illustrates how you can send messages using Azure Queue Storage.

Add a message to a queue in Azure Queue Storage

You can add a message to queue in Azure Queue Storage using the SendMessage method.

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Editor @ DevStyleR