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, 2019 in Azure by sabby
• 4,390 points
4,294 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);


Hope it helps!

If you need to know more about Azure, then you should join Azure cloud certification course today.

Thank you!!

answered Apr 12, 2019 by Prerna
• 1,960 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, 2019 in Azure by Perry
• 17,100 points
2,312 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
• 58,090 points
7,008 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
• 58,090 points
4,448 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
16,187 views
0 votes
1 answer

How to add a body to a HttpWebRequest that is being used with the Azure Service management API?

The following code should help: byte[] buf = ...READ MORE

answered Apr 3, 2019 in Azure by Prerna
• 1,960 points
2,036 views
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, 2019 in Azure by Perry
• 17,100 points
1,128 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, 2019 in Azure by Perry
• 17,100 points
885 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 26, 2019 in Azure by Prerna
• 1,960 points
3,260 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP