Javier Buffa
Javier Buffa

Reputation: 101

Is there a ContinuationToken for Azure.Storage.Queue in version 12+

I'm working on a Access layer to connect my program to the azure queue storage and get a list of all queues. I'm using the Azure.Storage.Queues.QueueServiceClient to get all queues and list then.

this is what im trying to do:

public IEnumerable<QueueItem> GetQueueList()
    {
        var queues = new List<QueueItem>();
        var serviceClient = new QueueServiceClient(_connectionStrings.myConnectionString);            
        var queues = serviceClient.GetQueues();
        QueueContinuationToken continuationToken = null;
        do
        {
            var queue = queues.AsPages(continuationToken);
            continuationToken = queue.ContinuationToken;
            queues.AddRange(queue);
        }
        while (continuationToken != null);
        return queues;

What I'm needing is something similar to the QueueContinuationToken from version 11, but I'm not able to find anything related, just the deprecated version of the continuation token.


UPDATE

I've found a way to work arround this, but it has nothing to do with the ContinuationToken.

The code looks like this

public async Task<IEnumerable<QueueItem>> GetQueueListAsync()
    {                        
        var queueServiceClient = new QueueServiceClient(_connectionStrings.MyConnectionString);
        IAsyncEnumerable<Page<QueueItem>> queues = queueServiceClient.GetQueuesAsync().AsPages();
        var result = new List<QueueItem>();           
        await foreach(var page in queues)
        {
            foreach (var queue in page.Values)
            {
                result.Add(queue);
            }
        }
        return result;
    }

Upvotes: 3

Views: 435

Answers (1)

kavya Saraboju
kavya Saraboju

Reputation: 10831

As suggested by John in the comment section , one may try foreach(var queue in queues) to get queue list which simplifies the code.

Thanks @john Hanley for your answer.

Upvotes: 2

Related Questions