I don't think there is a direct solution for this. You can use the GetPartitionKeyStatisticsAsync
method to get statistics about the partition keys.
Similar functionality is available in the Node.js SDK.
var container = client.GetContainer("databaseId", "containerId");
var partitionKeyStats = await container.ReadPartitionKeyStatisticsAsync(partitionKeyValue);
Console.WriteLine($"Partition key: {partitionKeyValue}, Size: {partitionKeyStats.SizeInKB} KB");
You can enable diagnostics logs for your CosmosDB account. These logs contain detailed metrics that can be used to analyze the size of data per partition key. After exporting them to a Log Analytics workspace, you can run queries to analyze the data size per partition key.
AzureDiagnostics
| where ResourceType == "COSMOSDB_ACCOUNTS"
| where OperationName == "MongoDBRequest"
| summarize TotalSize = sum(toint(parse_json(RequestBody).size)) by PartitionKey
| order by TotalSize desc