We have a few tables that sit in Azure Storage Tables (NOT Azure SQL Tables), and I cant find an easy way to give me a count of the number of rows in a table.
I have tried calling .CreateQuery.Count(), but that simply returns:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>InvalidInput</code>
<message xml:lang="en-US">One of the request inputs is not valid.
RequestId:c74f8b4c-4277-42f6-bb5d-0db187358e43
Time:2011-12-21T10:34:12.5379616Z</message>
</error>
Step 8: The row counts are just aggregate transformation, to create a row counts go to Aggregate settings and use the function count(1). This will create a running count of every row.
To view table data. In Cloud Explorer, open the Azure node, and then open the Storage node. Open the storage account node that you are interested in, and then open the Tables node to see a list of tables for the storage account. Open the shortcut menu for a table, and then select View Table.
Azure table storage is being deprecated in favor of Azure Cosmos DB. Azure Cosmos DB offers many advantages over Azure table storage, such as: -Azure Cosmos DB is scalable.
The row key is a unique identifier for an entity within a given partition. Together the PartitionKey and RowKey uniquely identify every entity within a table. The row key is a string value that may be up to 1 KiB in size. You must include the RowKey property in every insert, update, and delete operation.
This is because there is no Count operation for the Table Service: http://msdn.microsoft.com/en-us/library/windowsazure/dd179423.aspx You might be able (but I am not 100% sure) to get the count of record if you specify at least a partition key, or more criterias.
If you really want to count all rows you'll need to make paging requests. Every page returns a maximum of 1000 rows. After loading all in-memory, you can do a simple Linq Count()
.
You can count only pages and last page row number. This will save you lots of memory.
But beware, every page request with max rows returned equals one transaction. Performance wise, you'll actualy load whole table in memory which can be "uh-oh".
Link to sample code: http://scottdensmore.typepad.com/code/Continuation.zip
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With