-
Notifications
You must be signed in to change notification settings - Fork 46
Get CosmosDbDocumentJson
Return documents from a Cosmos DB database collection as a JSON string.
Get-CosmosDbDocumentJson -Context <Context> [-Key <SecureString>] [-KeyType <String>]
[-Database <String>] -CollectionId <String> [-Id <String>]
[-PartitionKey <Object[]>] [-MaxItemCount <Int32>] [-ContinuationToken <String>]
[-ConsistencyLevel <String>] [-SessionToken <String>]
[-PartitionKeyRangeId <String>] [-Query <String>] [-QueryParameters <Hashtable[]>]
[-QueryEnableCrossPartition <Boolean>] [-ResponseHeader <PSReference>] [<CommonParameters>]
Get-CosmosDbDocumentJson -Account <String> [-Key <SecureString>] [-KeyType <String>]
[-Database <String>] -CollectionId <String> [-Id <String>]
[-PartitionKey <Object[]>] [-MaxItemCount <Int32>] [-ContinuationToken <String>]
[-ConsistencyLevel <String>] [-SessionToken <String>]
[-PartitionKeyRangeId <String>] [-Query <String>] [-QueryParameters <Hashtable[]>]
[-QueryEnableCrossPartition <Boolean>] [-ResponseHeader <PSReference>] [<CommonParameters>]
This cmdlet will return the documents for a specified collection in a Cosmos DB database. If an Id is specified then only the specified documents will be returned.
A maximum of 100 document will be returned if an Id is not specified. To retrieve more than 100 documents a continuation token will need to be used.
PS C:\> Get-CosmosDbDocumentJson -Context $cosmosDbContext -CollectionId 'MyNewCollection' -Id 'ac12345'
Return a document with a Id 'ac12345' from a collection in the database.
PS C:\> $ResponseHeader = $null
PS C:\> $documents = Get-CosmosDbDocumentJson -Context $cosmosDbContext -CollectionId 'MyNewCollection' -MaxItemCount 5 -ResponseHeader ([ref] $ResponseHeader)
PS C:\> $continuationToken = Get-CosmosDbContinuationToken -ResponseHeader $ResponseHeader
Get the first 5 documents from the collection in the database storing a continuation token.
PS C:\> $documents = Get-CosmosDbDocumentJson -Context $cosmosDbContext -CollectionId 'MyNewCollection' -MaxItemCount 5 -ContinuationToken $continuationToken
Get the next 5 documents from a collection in the database using the continuation token found in the headers from the previous example.
PS C:\> $query = "SELECT * FROM customers c WHERE (c.id = '[email protected]')"
PS C:\> Get-CosmosDbDocumentJson -Context $cosmosDbContext -CollectionId 'MyNewCollection' -Query $query
Query the documents in a collection.
PS C:\> $query = "SELECT * FROM customers c WHERE (c.id = @id)"
PS C:\> $queryParameters = @(
@{ name = "@id"; value="[email protected]"; }
)
PS C:\> Get-CosmosDbDocumentJson -Context $cosmosDbContext -CollectionId 'MyNewCollection' -Query $query -QueryParameters $queryParameters
Query the documents in a collection using a parameterized query.
The account name of the Cosmos DB to access.
Type: String
Parameter Sets: Account
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This is the id of the collection to get the documents for.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This is the consistency level override. The override must be the same or weaker than the account's configured consistency level. Should not be set if Id is set.
Type: String
Parameter Sets: (All)
Aliases:
Accepted values: Strong, Bounded, Session, Eventual
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This is an object containing the context information of the Cosmos DB database that will be deleted. It should be created by `New-CosmosDbContext`.
Type: Context
Parameter Sets: Context
Aliases: Connection
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
A string token returned for queries and read-feed operations if there are more results to be read. Should not be set if Id is set.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The name of the database to access in the Cosmos DB account.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This is the id of the document to return.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The key to be used to access this Cosmos DB.
Type: SecureString
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The type of key that will be used to access ths Cosmos DB.
Type: String
Parameter Sets: (All)
Aliases:
Accepted values: master, resource
Required: False
Position: Named
Default value: Master
Accept pipeline input: False
Accept wildcard characters: False
An integer indicating the maximum number of items to be returned per page. Should not be set if Id is set.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: -1
Accept pipeline input: False
Accept wildcard characters: False
The partition key value(s) for the document to be read. Must be included if and only if the collection is created with a partitionKey definition.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The partition key range Id for reading data. Should not be set if Id is set.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
A SQL select query to execute to select the documents. This should not be specified if Id is specified.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
If the collection is partitioned, this must be set to True to allow execution across multiple partitions. This should only be specified if Query is specified.
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This is an array of key value pairs (Name, Value) that will be passed into the SQL Query. This should only be specified if Query is specified.
Type: Hashtable[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This is a reference variable that will be used to return the hashtable that contains any headers returned by the request.
Type: PSReference
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
A string token used with session level consistency. Clients must echo the latest read value of this header during read requests for session consistency. Should not be set if Id is set.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
- ConvertTo-CosmosDbTokenDateString
- Get-CosmosDbAccount
- Get-CosmosDbAccountConnectionString
- Get-CosmosDbAccountMasterKey
- Get-CosmosDbAttachment
- Get-CosmosDbAttachmentResourcePath
- Get-CosmosDbAuthorizationHeaderFromContext
- Get-CosmosDbCollection
- Get-CosmosDbCollectionResourcePath
- Get-CosmosDbDatabase
- Get-CosmosDbDatabaseResourcePath
- Get-CosmosDbDocument
- Get-CosmosDbDocumentResourcePath
- Get-CosmosDbEntraIdToken
- Get-CosmosDbOffer
- Get-CosmosDbOfferResourcePath
- Get-CosmosDbPermission
- Get-CosmosDbPermissionResourcePath
- Get-CosmosDbStoredProcedure
- Get-CosmosDbStoredProcedureResourcePath
- Get-CosmosDbTrigger
- Get-CosmosDbTriggerResourcePath
- Get-CosmosDbUri
- Get-CosmosDbUser
- Get-CosmosDbUserDefinedFunction
- Get-CosmosDbUserDefinedFunctionResourcePath
- Get-CosmosDbUserResourcePath
- Invoke-CosmosDbRequest
- Invoke-CosmosDbStoredProcedure
- New-CosmosDbAccount
- New-CosmosDbAccountMasterKey
- New-CosmosDbAttachment
- New-CosmosDbBackoffPolicy
- New-CosmosDbContext
- New-CosmosDbCollection
- New-CosmosDbCollectionExcludedPath
- New-CosmosDbCollectionIncludedPath
- New-CosmosDbCollectionIncludedPathIndex
- New-CosmosDbCollectionIndexingPolicy
- New-CosmosDbCollectionUniqueKey
- New-CosmosDbCollectionUniqueKeyPolicy
- New-CosmosDbDatabase
- New-CosmosDbDocument
- New-CosmosDbInvalidArgumentException
- New-CosmosDbInvalidOperationException
- New-CosmosDbPermission
- New-CosmosDbStoredProcedure
- New-CosmosDbTrigger
- New-CosmosDbUser
- New-CosmosDbUserDefinedFunction
- Remove-CosmosDbAccount
- Remove-CosmosDbAttachment
- Remove-CosmosDbCollection
- Remove-CosmosDbDatabase
- Remove-CosmosDbDocument
- Remove-CosmosDbPermission
- Remove-CosmosDbStoredProcedure
- Remove-CosmosDbTrigger
- Remove-CosmosDbUser
- Remove-CosmosDbUserDefinedFunction
- Set-CosmosDbAccount
- Set-CosmosDbAttachment
- Set-CosmosDbAttachmentType
- Set-CosmosDbCollectionType
- Set-CosmosDbDatabaseType
- Set-CosmosDbDocument
- Set-CosmosDbDocumentType
- Set-CosmosDbOffer
- Set-CosmosDbOfferType
- Set-CosmosDbPermissionType
- Set-CosmosDbStoredProcedure
- Set-CosmosDbStoredProcedureType
- Set-CosmosDbTrigger
- Set-CosmosDbTriggerType
- Set-CosmosDbUser
- Set-CosmosDbUserDefinedFunction
- Set-CosmosDbUserDefinedFunctionType
- Set-CosmosDbUserType