-
Notifications
You must be signed in to change notification settings - Fork 46
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
Get-CosmosDbDocument doesn't get all documents #354
Comments
Hi @Panzerbjrn - the Specifically: The Maximum response size (for example, paginated query) is 4MB. Therefore, I suspect those 731 documents are just under 4MB and so CosmosDB is cutting it off there. So what you want to do is use a continuation token to retrieve the documents following. You could do this in a while loop reasonably easily (I haven't tested this code but it should be correct): $documentsPerRequest = 20
$continuationToken = $null
$documents = $null
do {
$responseHeader = $null
$getCosmosDbDocumentParameters = @{
Context = $cosmosDbContext
CollectionId = 'MyNewCollection'
MaxItemCount = $documentsPerRequest
ResponseHeader = ([ref] $responseHeader)
}
if ($continuationToken) {
$getCosmosDbDocumentParameters += {
ContinuationToken = $continuationToken
}
}
$documents += Get-CosmosDbDocument @getCosmosDbDocumentParameters
$continuationToken = [System.String] $responseHeader.'x-ms-continuation'
} while (-not [System.String]::IsNullOrEmpty($continuationToken)) Does that make sense? I should probably add the above code as a sample into the README (after I test it 😁). |
Yessssssssssssssssssssssssssssssssssssssss, that makes sense and mostly works. I have to admit that I don't quite get how the continuation token works, but it does... Oddly, I was getting this error.
So I changed
to |
Opening this again so I can add this example to the documentation. |
Issue
Get-Module -Name CosmosDB
)Hi all, when I use Get-CosmosDbDocument, example
Get-CosmosDbDocument -Context $CosmosDbContext -CollectionId $CosmosCollection
, I only get 731 documents returned (out of 36255).I tried the parameter
-MaxItemCount 800
, but still only received 731 documents.If I use
| select -Skip 500
I get 231, which makes sense, but it was worth trying.Is this a bug? Or intentional limitation? How would I get all documents when
-MaxItemCount
doesn't seem to do anything?I also don't get any errors, which seems odd.
Thanks.
The text was updated successfully, but these errors were encountered: