List Azure Storage Queues
This document outlines how to list queues within your Azure Storage account using various methods, including the Azure CLI, Azure PowerShell, and REST API.
Prerequisites
Before you begin, ensure you have the following:
- An Azure Storage account. If you don't have one, you can create one here.
- Appropriate permissions to access the storage account.
Using Azure CLI
The Azure CLI provides a straightforward way to list queues. Replace <storage-account-name> with your actual storage account name.
az storage queue list --account-name <storage-account-name>
This command will return a JSON array of queue objects, each containing the queue name.
Using Azure PowerShell
Azure PowerShell offers similar functionality. You can list queues using the Get-AzStorageQueue cmdlet.
Get-AzStorageQueue -Context (Get-AzStorageAccount -ResourceGroupName <resource-group-name> -Name <storage-account-name>).Context
If you have set the context using Set-AzStorageAccount, you can simply use:
Get-AzStorageQueue
Using Azure Storage REST API
You can also list queues directly using the Azure Storage REST API. The following request lists queues for a given storage account:
GET https://<storage-account-name>.queue.core.windows.net/?comp=list HTTP/1.1
x-ms-version: 2020-08-04
Authorization: SharedKey <storage-account-name>:<signature>
Date: <date>
Host: <storage-account-name>.queue.core.windows.net
You will need to generate a SharedKey signature. Refer to the Authorize with Shared Key documentation for details.
Using Azure SDKs
Azure provides SDKs for various languages (e.g., Python, .NET, Java, Node.js) that abstract the REST API calls. Here's a Python example:
from azure.storage.queue import QueueServiceClient
connection_string = "DefaultEndpointsProtocol=https;AccountName=;AccountKey=;EndpointSuffix=core.windows.net"
queue_service_client = QueueServiceClient.from_connection_string(connection_string)
print("Queues in the storage account:")
for queue_item in queue_service_client.list_queues():
print(f"- {queue_item.name}")
Output Example
A typical output from listing queues might look like this:
[
{
"name": "order-processing-queue"
},
{
"name": "email-notifications"
},
{
"name": "log-storage"
}
]
Summary
Listing Azure Storage Queues is a fundamental operation when working with Azure Queue Storage. Whether you prefer command-line tools, scripting, or programming, Azure provides multiple options to effectively manage your queues.