CloudQueueClient.ListQueues Method (String)
From Storage Client Library NET API
Returns an enumerable collection of the queues in the storage account whose names begin with the specified prefix.
Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)
Usage
| Visual Basic |
|---|
Dim instance As CloudQueueClient Dim prefix As String Dim returnValue As IEnumerable(Of CloudQueue) returnValue = instance.ListQueues(prefix) |
Syntax
| Visual Basic |
|---|
Public Function ListQueues ( _ prefix As String _ ) As IEnumerable(Of CloudQueue) |
| C# |
|---|
public IEnumerable<CloudQueue> ListQueues ( string prefix ) |
| C++ |
|---|
public: IEnumerable<CloudQueue^>^ ListQueues ( String^ prefix ) |
| J# |
|---|
| JScript |
|---|
Parameters
- prefix
Type: System.String
The queue name prefix.
Return Value
Type: System.Collections.Generic.IEnumerable
An enumerable collection of queues.
Example
The following code example lists all of the queues in the account, next lists queues beginning with a specified prefix, and finally lists queues with metadata included in the listing.
static void ListQueuesInAccount(Uri queueEndpoint, string accountName, string accountKey)
{
//Create service client for credentialed access to the Queue service.
CloudQueueClient queueClient = new CloudQueueClient(queueEndpoint, new StorageCredentialsAccountAndKey(accountName, accountKey));
//List all of the queues in account.
foreach(var queue in queueClient.ListQueues())
{
Console.WriteLine(queue.Name);
}
Console.WriteLine();
//List all of the queues in account beginning with the specified prefix.
foreach(var queue in queueClient.ListQueues("my"))
{
Console.WriteLine(queue.Name);
}
Console.WriteLine();
//List all of the queues in account beginning with the specified prefix, and also return queue metadata.
foreach (var queue in queueClient.ListQueues("my", QueueListingDetails.Metadata))
{
Console.WriteLine(queue.Name);
//Enumerate the queue's metadata.
foreach (var metadataKey in queue.Metadata.Keys)
{
Console.WriteLine("\tMetadata name: " + metadataKey.ToString());
Console.WriteLine("\tMetadata value: " + queue.Metadata.Get(metadataKey.ToString()));
}
}
Console.WriteLine();
}
| |
Remarks
The ListQueues method will return all queues in the storage account. The ListQueues method enumerates queues lazily, so results are retrieved from the server as they are needed.
To list queues in pages of a specified size, use the ListQueuesSegmented or BeginListQueuesSegmented method.