Get all partition keys in an Azure Cosmos DB gallery
UPDATE: As per Brian in the comments below, DISTINCT
now supported. Try something like:
SELECT DISTINCT c.partitionKey FROM c
Previous answer ...
The only way to get the actual values โโof the keys of the sections is to make a unique aggregate on this field. However, there is a relatively simple way to get the key ranges of a section. It is not directly supported in any of the SDKs as far as I know, but you can directly hit the REST endpoint in https://{your endpoint domain}.documents.azure.com/dbs/{your collection uri fragment}/pkranges
to override the ranges for the section keys for each section. Please note: the bottom side is included, so you can use it to make your own fan.
Warning. There is a small chance that pkranges could change between the time they were fetched and the time you intend to do something with them. Either take that subtle risk or the code around it.
source to share