Search code examples
azure-cosmosdb

How to find unique keys, tabel storage size in CosmosDB container?


I am learning CosmosDB (coming from AWS Dynamo) and struggling to find some base info about the container from UI, such as following. I am looking into https://learn.microsoft.com/en-us/azure/cosmos-db/index-overview this but so far I have not found needed info.

  • How to see total size of the container? In Dynamo, you would see that under overview section, but I do not see such for CosmosDB.
  • How to see unique keys? I can see partition key under settings but like Dynamo, is there a way to see all indexes such as Global indexes? I checked Indexing Policy for CosmosDB, but don't see any info regarding keys. Does that mean this container doesn't have any unique keys?

I tried to find such info online, but couldn't. For Cosmos, I want to find out which unique keys I have to create based on my requirements. But, lets the container is already created by someone else, and I want to see info about unique keys, etc. How can I do that? Same with container size.

enter image description here

enter image description here


Solution

  • The Azure Portal doesn't show everything for a container unfortunately.

    The best way to get all the information for a container is to use PowerShell or Azure CLI. Example below

    az cosmosdb sql container show -g myResourceGroup -a mycosmosaccount -d myDatabase -n myContainer
    

    This will show everything. Partition key, index policy, unique keys and will also show storage size by physical partition. Just add up for entire container.