Warm tip: This article is reproduced from stackoverflow.com, please click
.net-core azure-cosmosdb

Query Cosmos DB for all partitions

发布于 2020-03-27 15:44:45

I am thinking of creating a reporting tool for a Cosmos DB instance in our system. I want to discover all the partition keys and the number of items stored for each. I think I should be using pkranges but do not seem to be able to find any examples of how this should work. Any suggestions?

Questioner
onesixtyfourth
Viewed
72
Bob Ash 2020-01-31 19:05

You can try to get list of pkranges using this api

As of now, there is no api to return list of partition keys. There was a feature request at Azure Cosmos DB Improvement Ideas, but it is declined.

So, you can try "SELECT distinct c.partitionKey FROM c" to get list of distinct partition keys.