Quering all the rows in Azure table Storage.

0 votes

I am trying to get a list of all entities inside my Azure table. How should I be writing this query in c#?

Apr 12 in Azure by sabby
• 4,370 points
41 views

1 answer to this question.

0 votes

Refer the following code:

var acc = new CloudStorageAccount(
                         new StorageCredentials("account name", "account key"), false);
var tableClient = acc.CreateCloudTableClient();
var table = tableClient.GetTableReference("table name");
var entities = table.ExecuteQuery(new TableQuery<MyEntity>()).ToList();

However please keep in mind that table service returns a maximum of 1000 entities in a single call to it. If there're more than 1000 entities available in your table, it returns a continuation token which can be used to fetch next set of entities.

So, a better approach would be to use ExecuteQuerySegmented method and have your application deal with the token. Here's the sample code to do so:

var acc = new CloudStorageAccount(
                         new StorageCredentials("account name", "account key"), false);
var tableClient = acc.CreateCloudTableClient();
var table = tableClient.GetTableReference("table name");
TableContinuationToken token = null;
var entities = new List<MyEntity>();
do
{
    var queryResult = table.ExecuteQuerySegmented(new TableQuery<MyEntity>(), token);
    entities.AddRange(queryResult.Results);
    token = queryResult.ContinuationToken;
} while (token != null);
answered Apr 12 by Prerna
• 1,940 points

Related Questions In Azure

0 votes
1 answer

Is there any number limitation in Azure Storage Table query entities?

ExecuteQuery method handles continuation token internally and ...READ MORE

answered Jul 4 in Azure by Perry
• 17,090 points
53 views
0 votes
2 answers

In Azure powershell Select-AzureSubscription command fetching error: the subscription name doesn't exist

The problem you're having is that the ...READ MORE

answered Aug 16, 2018 in Azure by Priyaj
• 57,300 points
1,951 views
0 votes
2 answers

How can I view the deployed files in Azure?

In Visual Studio, in the window "Server ...READ MORE

answered Aug 21, 2018 in Azure by Priyaj
• 57,300 points
356 views
+1 vote
10 answers

How can the NuGet packages be used in Azure Functions?

Yes! Although the Azure Functions portal does ...READ MORE

answered Jun 8, 2018 in Azure by club_seesharp
• 3,450 points
5,576 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to Schedule a task in Azure Worker role?

You can simply have a message on ...READ MORE

answered Jul 1 in Azure by Perry
• 17,090 points
84 views
0 votes
1 answer

I want to queue time-based tasks in Azure

You need to use a scheduled task. ...READ MORE

answered Jul 2 in Azure by Perry
• 17,090 points
31 views
0 votes
1 answer

How to pass object messages in Azure Queue Storage?

I already have a base class, so ...READ MORE

answered Mar 25 in Azure by Prerna
• 1,940 points
313 views
0 votes
1 answer