Today, almost every software application is made up of independent components that require constant communication with each other. Moreover, developers who build such applications are looking for ways to ensure that this communication is secure from third-party attacks and server crashes. This is where Azure jumps in!

Azure is a collection of messaging systems that allow developers to create safe and reliable communication between their application modules. Moreover, Azure Queue Storage offers scalable storage coupled with high processing power which facilitates optimal asynchronous messaging. 

This article introduces Azure and its key features. It also elaborates on the various concepts important in Azure Queue Storage. The article further provides a step-by-step guide for installing Azure Queue Service on your system using Python, Java, and Node. JS. Read along to learn the steps and importance of this Microsoft tool. 

Prerequisites

  • Install Python.
  • Create an Azure account.

What is Microsoft Azure?

Azure Queue Storage - Azure Logo | Hevo Data

Microsoft Azure is a service offered by Microsoft that provides you with scalable storage space and high computing power.  You can utilize Azure in various forms including Infrastructure as a Service (IaaS), Software as a Service (SaaS), and Platform as a Service (Paas).

To facilitate their businesses on Cloud, 80% of Fortune 500 companies deploy Azure’s public domain services. Moreover, with Azure,  you can ensure the total safety of your cloud data will and create data backups to withstand unexpected server crashes.

As a developer, you can choose any of the above-mentioned 3 models and create robust applications. You can also use Azure to host existing applications on its public cloud. Furthermore, you can generate VMs (Virtual Machines) and databases by using Microsft Azure services.

Key Features of Microsoft Azure

You can facilitate Data Management by depending on the following features of Microsoft Azure:

  • Analytics Support: Azure contains in-built tools for performing Data Analysis and Reporting. You can leverage these tools to extract valuable insights from your vast business data. Such insights empower you to search for new leads, improve customer service, and make data-driven decisions for your business. 
  • Hybrid Ready: Azure can work with both on-premises data centers and online public cloud facilities. This implies you can select one of these options to cater to your business needs and even opt for the Hybrid model and enjoy the benefits of both models.
  • Efficient Storage System: The Azure storage is full of working delivery points and data centers. This allows you to operate on a rapid data delivery rate and enhance your customers’ experience.

Important Concepts in Azure Queue Storage

The following entities make Azure Queue Storage functional:

Queue

The Queue represents the storage part of Azure that is useful for saving a vast sea of messages. A single Azure Queue can store millions of messages each of which can be of the size 64 KB or smaller. The upper limit of Queue’s storage is decided by the type of Storage Account that you’re currently using.

Moreover, you can access these messages via HTTP or HTTPS calls from anywhere around the globe. Azure Queues finds applications in businesses that are looking to build a backlog of their work asynchronously.

The below diagram represents the relationship between Queue and Storage Account.

Azure Queue Storage - Queue and Storage Connection | Hevo Data
Image Source

Storage Account

A Storage Account is an intermediary entity that allows you to access and manipulate Azure Storage. Every Azure user must, as a basic requirement, create a Storage Account before using any of the Azure services.

A Storage Account carries every essential data object that you will use in Azure including, File Storage, Queue Storage, etc. 

A Storage Account provides an exclusive Azure namespace to your data. This implies all of your objects in the Azure storage will get an address in terms of a unique account name. Combining this account name with Azure service endpoints will allow you to access your data present in any Azure Object. 

URL Format

The Queues which you access using the Storage Account are addressable. Such Azure Queues contain URLs that must be in the below format:

https://<storage account>.queue.core.windows.net/<queue>

For instance, you can access the Azure Queue Storage shown in the below diagram with the following URL:


https://myaccount.queue.core.windows.net/images-to-download

Message

A message in Azure represents the data that you want to transfer via its Queues. The maximum size of a message in Azure, irrespective of its format, is 64 KB.

Moreover, depending on the version you use, a message’s time-to-live is different in Azure. Therefore, in versions before 2017-07-29, your message stays alive for seven days while in later versions, you can set any positive number as the message’s life.

Furthermore, you can set -1 as the message’s time-to-live thus declaring this message as unexpirable. 

Importance of Azure Queue Storage

Implementing the Azure Queue Storage system is beneficial if your application contains multiple components that require regular communication with each other yet stay independent from each other. You can also leverage the Queue Storage to manage the asynchronous processing of a lengthy task.

It even allows you to scale up or down by simply adding or deleting the consumers according to your requirements. Moreover, using Azure Queue Storage will empower your system and make it resilient to server crashes.

This will allow producers to push messages into Azure Queue, and save the message in the queue if no consumer is available. This implies, that even if the consumer services of your system are down, they can still access the message later when they are backing up.

Methods to Set Up Azure Queue Storage

The previous section discussed the importance of Azure Queue Storage and explained its core concepts. Next, you can implement the following methods to set up your own Azure Queues in no time:

Using Java

The following steps will help you in creating a Java application (named playing-with-queues) in Azure:

Step 1: Create a Java Application

Open a new console window (cmd, Bash, or PowerShell ) and using Maven, create a new application named playing-with-queues. You can use the following maven code to create the required application: 

If you are using Bash:


 mvn archetype:generate 
     --define interactiveMode=n 
     --define groupId=com.queues.howto 
     --define artifactId=playing-with-queues 
     --define archetypeArtifactId=maven-archetype-quickstart 
     --define archetypeVersion=1.4

If you are using PowerShell:

mvn archetype:generate `
    --define interactiveMode=n `
    --define groupId=com.queues.playing `
    --define artifactId=playing-with-queues `
    --define archetypeArtifactId=maven-archetype-quickstart `
    --define archetypeVersion=1.4

The output of the above lines will look similar to the following:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.1.2:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.1.2:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.1.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Batch mode
[INFO] ----------------------------------------------------------------------------
[INFO] Using the following parameters for creating a project from Archetype: maven-archetype-quickstart:1.4
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.queues.playing
[INFO] Parameter: artifactId, Value: queues-playing
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.queues.playing
[INFO] Parameter: packageInPathFormat, Value: com/queues/playing
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.queues.playing
[INFO] Parameter: groupId, Value: com.queues.playing
[INFO] Parameter: artifactId, Value: queues-playing-with
[INFO] Project created from Archetype in dir: C:queuesqueues-playing-with
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.775 s
[INFO] Finished at: 2020-08-17T15:27:31-07:00
[INFO] ------------------------------------------------------------------------

Now, switch to your new queues-playing-with directory, type:

cd queues-playing-with

Next, in your text editor, start the pom.xml file and write the following code to the existing dependencies:

XML

<dependency>
  <groupId>com.azure</groupId>
  <artifactId>azure-storage-queue</artifactId>
  <version>12.6.0</version>
</dependency>

Step 2: Configure Your Java Application and access Azure Queue Storage

Go to your Java application file and navigate to the location where you wish to use Azure APIs to access its storage. Write the following commands at the top of that Java application’s code: 

import com.azure.core.util.*;
import com.azure.storage.queue.*;
import com.azure.storage.queue.models.*;

Step 3: Set up the Connection String for Azure Queue Storage

An Azure Connection String allows clients to access Data Management Services. Next, fetch the name and the primary key (access) of your Storage Account from the Azure portal. Use the fetched configurations in place of the AccountName & AccountKey options in the connection string. 

The following example represents the process to declare a static field to manage a connection string:

final String connectStr = 
    "DefaultEndpointsProtocol=https;" +
    "AccountName=your_storage_account;" +
    "AccountKey=your_storage_account_key";

That’s it! Your Azure Queue Storage using Java is in place. You can now perform various operations on this Queue and manipulate your application messages. To learn more about the operations, visit here.

Using Python

Once you install the Python environment in your system, perform the following steps:

Step 1: Install Azure Storage Queue for Python

After downloading the Azure SDK, install the Azure Storage Queue using PyPI (Python Package Index):

pip install azure-storage-queue

Step 2: Get your Azure Portal Credentials

You have to authorize the requests of your sample application to Azure. To authorize requests, add your credentials of the Storage Account as a connection string to your application. Next, sign in to the Azure portal and locate your Storage Account.

In the menu visible on your screen, navigate to Security+networking and open it. Now, click on Access Keys. Your screen will look similar to the below image. 

Access Keys | Hevo Data
Access Keys

Now, in the Access keys pane, click on Show keys. Go to the key1 section and find  Connection string value. Click on the Copy to clipboard icon and add the connection string to your clipboard.  

Step 2: Configure the Storage Connection String

After copying the connection string, paste it to any new environment variable on your system. Now, open your console window, and replace <yourconnectionstring> with the actual connection string. For instance, you can use the following code in Windows:

setx AZURE_STORAGE_CONNECTION_STRING "<yourconnectionstring>"

Now, start a new instance of your command window. Moreover, restart any currently running programs that may use the environment variable.

What Makes Hevo’s Data Streaming and Loading Unique

Hevo is the only real-time ELT No-code Data Pipeline platform that cost-effectively automates data pipelines that are flexible to your needs. With integration with 150+ Data Sources (40+ free sources), we help you not only export data from sources & load data to the destinations but also transform & enrich your data, & make it analysis-ready.

Start for free now!

Schedule a Demo

Step 3: Configure Your Application and Access the Azure Queue Storage

The QueueClient object in Python will allow you to work with queues. Go to your Python application file and add the following code:

from azure.storage.queue import (
        QueueClient,
        BinaryBase64EncodePolicy,
        BinaryBase64DecodePolicy
)

import os, uuid

The os package will allow you to retrieve an environment variable and the uuid package is to generate a unique identifier for your queue name.

Using Node.JS

The following steps will help you in setting up Azure Queue Storage using Node.JS:

Step 1: Configure your Node.JS Application and Access Storage

The Azure Storage client library in JavaScript contains a set of libraries that can easily communicate with the storage’s REST services. You can install the Azure Storage Queue for Node.JS using the following code in your sample application:

npm install @azure/storage-queue

Step 2: Add the Required Module

To verify that your node_modules folder is ready, navigate to the required folder and you must find the @azure/storage-queue package. This will contain the necessary client library required to access storage.

Now, using your editor, place the following code at the top of your JavaScript file where you wish to use queues:

const { QueueClient, QueueServiceClient } = require("@azure/storage-queue");

That’s it! Your Node.JS application is ready to interact with Azure Queue Storage.

Learn More About:

Better Understand Azure Message Queue With This Detailed Guide

Conclusion

The article introduced you to Azure and discussed its key features. It then explained the importance of Azure storage Queues and listed their various components. Furthermore, the article provided a step-by-step discussion of methods to set up Azure Storage Queues for your applications in Java, Python, and Node.JS. 

Now, to perform Data Analytics on your Azure data, you first need to export this data to a Data Warehouse. This will require you to custom-code complex scripts to develop the ETL processes.

Hevo Data can automate your data transfer process, hence allowing you to focus on other aspects of your business like Analytics, Customer Management, etc.

This platform allows you to transfer data from 150+ multiple sources like Azure to Cloud-based Data Warehouses like Amazon Redshift, Snowflake, Google BigQuery, etc. It will provide you with a hassle-free experience and make your work life much easier.

Want to take Hevo for a spin? Sign Up or a 14-day free trial and experience the feature-rich Hevo suite firsthand. Also checkout our unbeatable pricing to choose the best plan for your organization.

Share your understanding of Azure Queue Storage in the comments below!

Suraj Poddar
Principal Frontend Engineer, Hevo Data

Suraj has over a decade of experience in the tech industry, with a significant focus on architecting and developing scalable front-end solutions. As a Principal Frontend Engineer at Hevo, he has played a key role in building core frontend modules, driving innovation, and contributing to the open-source community. Suraj's expertise includes creating reusable UI libraries, collaborating across teams, and enhancing user experience and interface design.