Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Return the size of a collection #79

WatersJohn opened this Issue Apr 8, 2018 · 2 comments


None yet
2 participants
Copy link

commented Apr 8, 2018

Following the guidance, I'm writing an issue prior to submitting an enhancement.

When you use non-partitioned collections, Microsoft imposes a hard size limit of 10 GB. Microsoft allows you to set up alerting based on size, but it is the aggregate account size, not the collection size, rendering it moot.

The CosmosDB PowerShell module contains a lot of the foundation plumbing required to get this information. I've written a small enhancement to return size information about a collection. indicates that this info can be retrieved by doing a GET on the collection, and the response contains usage information for the collection in the x-ms-resource-usage header.

The design introduces a new function in lib\collections.ps1 named Get-CosmosDBCollectionSize which returns information for a given collection, and leaves the existing Get-CosmosDBCollection function untouched. The params for Get-CosmosDBCollectionSize are identical to Get-CosmosDBCollection.

The response contains a hashtable containing the values of the following properties:
triggers, collectionSize, documentsCount, functions, storedProcedures, documentsSize, documentSize. Unfortunately, these do not appear to be documented; some discussion about the potential values are here:

With this enhancement, I've been able to set up basic alerting based on collection size. If this is of interest, I'm happy to submit a pull request.


This comment has been minimized.

Copy link

commented Apr 8, 2018

Hi @WatersJohn - this is awesome and I'd love to include this if you want to submit a PR. If you include a changelog entry in the file with your name then you'll get attribution of the feature in the release notes. Thank you very much for contributing!

WatersJohn added a commit to WatersJohn/CosmosDB that referenced this issue Apr 9, 2018

PlagueHO added a commit that referenced this issue Apr 9, 2018

Merge pull request #80 from WatersJohn/dev
#79 - Added Get-CosmosDBCollectionSize.

This comment has been minimized.

Copy link

commented Apr 9, 2018

Fixed by #80

@PlagueHO PlagueHO closed this Apr 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.