-
Notifications
You must be signed in to change notification settings - Fork 46
Get CosmosDbDocument
Return documents from a Cosmos DB database collection.
Get-CosmosDbDocument -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>]
[-ReturnJson <switch>] [<CommonParameters>]Get-CosmosDbDocument -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>]
[-ReturnJson <switch>] [<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-CosmosDbDocument -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-CosmosDbDocument -Context $cosmosDbContext -CollectionId 'MyNewCollection' -MaxItemCount 5 -ResponseHeader ([ref] $ResponseHeader)
PS C:\> $continuationToken = Get-CosmosDbContinuationToken -ResponseHeader $ResponseHeaderGet the first 5 documents from the collection in the database storing a continuation token.
PS C:\> $documents = Get-CosmosDbDocument -Context $cosmosDbContext -CollectionId 'MyNewCollection' -MaxItemCount 5 -ContinuationToken $continuationTokenGet 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-CosmosDbDocument -Context $cosmosDbContext -CollectionId 'MyNewCollection' -Query $queryQuery 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-CosmosDbDocument -Context $cosmosDbContext -CollectionId 'MyNewCollection' -Query $query -QueryParameters $queryParametersQuery the documents in a collection using a parameterized query.
PS C:\> Get-CosmosDbDocument -Context $cosmosDbContext -CollectionId 'MyNewCollection' -Id 'ac12345' -ReturnJsonReturn a document with a Id 'ac12345' from a collection in the database as JSON string rather than an object. This is useful if the document returned contain duplicate keys that differing only in case.
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: FalseThis 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: FalseThis 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: FalseThis 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: FalseA 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: FalseThe 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: FalseThis 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: FalseThe 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: FalseThe 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: FalseAn 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: FalseThe 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: FalseThe 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: FalseA 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: FalseIf 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: FalseThis 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: FalseThis 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: FalseA 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: FalsePrevents the information returned by Cosmos DB from the request to be converted into an object. This switch is required if the document being added to Cosmos DB has key names that are duplicates, differing only in case.
Type: switch
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseThis 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