我还要插入从父宇宙容器中批量获取的数据。我可以接收它,但是数据插入过程太慢了。我猜它每次迭代都会重新更新以前的批次。知道如何才能更快地提取这些数据吗?
Connect-AzAccount
$resourceGroupName = "resourceGroupName"
$accountName = "accountName"
$databaseName = "accountName"
$ParentContainer = "accountName"
$childContainername = "childContainername" $count=0
$ResponseHeader=$null
$cosmosDbContext = New-CosmosDbContext -Account $accountName -Database $databaseName -ResourceGroup $resourceGroupName #For using the connection variable for retrieving and inserting the data
$documents = Get-CosmosDbDocument -Context $cosmosDbContext -CollectionId $ParentContainer -MaxItemCount 10 -ResponseHeader ([ref] $ResponseHeader)
$continuationToken = Get-CosmosDbContinuationToken -ResponseHeader $ResponseHeader
$doc = Get-CosmosDbDocument -Context $cosmosDbContext -CollectionId $ParentContainer -MaxItemCount 10 -ResponseHeader ([ref] $ResponseHeader) -ContinuationToken $continuationToken
while ($continuationToken) {
$documents = Get-CosmosDbDocument -Context $cosmosDbContext -CollectionId $ParentContainer -MaxItemCount 10 -ResponseHeader ([ref] $ResponseHeader) -ContinuationToken $continuationToken
$totalDocs += $documents
$continuationToken = Get-CosmosDbContinuationToken -ResponseHeader $ResponseHeader
$doc=$totalDocs
foreach($item in $doc){
$Childdocument=$item |ConvertTo-Json
$Partition=$item.category
New-CosmosDbDocument -Context $cosmosDbContext -CollectionId $childContainername -DocumentBody $Childdocument -PartitionKey $Partition -Upsert $true
}
}