Are Azure Table Storage tables guaranteed to sort by Partition/Row?

Viewed 2037

When I execute this:

query = new azure.TableQuery().top(100).where("PartitionKey eq ?", someKey);

Does this guarantee that these 100 results will be returned in order by RowKey? Everything I read leads me to believe that there is a single order of records, and it's by the PartitionKey + RowKey. My own basic tests seem to confirm that. But I can't find any official documentation that comes right out and says it.

I just need to know if I can rely on that, or if it's something that could potentially change.

2 Answers

I can confirm that for Cosmos DB query results returned by the Table API aren't sorted in partition key/row key order as they're in Azure Table storage. - https://docs.microsoft.com/en-us/azure/cosmos-db/faq#where-is-table-api-not-identical-with-azure-table-storage-behavior

I raised this with them and pointed out the contradicting information in other documentation such as the log tail pattern mentioned above and they replied with "The https://docs.microsoft.com/en-us/azure/cosmos-db/table-storage-design-guide doc was initially written for Table storage only. Later when Table API in Cosmos DB and Azure Table storage are merged, the docs were brought to Cosmos DB space. I think there are some issues with the existing Table API docs and we are in the process of revamping our docs, will get to the Table API docs soon."

I almost fainted when I read their reply. How on earth can people migrate their apps from Azure Table Storage to CosmosDB without any sorting functionality. All you can really do is point queries which pretty much makes migrating Azure Table Storage to CosmosDB useless for my needs.

If you too would like to see CosmosDB index at least the RowKey in lexicographical order please upvote my CosmosDB suggestion: https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/36124006-table-api-sort

Related