Более быстрый способ вставки в Cosmos Db - PullRequest
0 голосов
/ 26 мая 2020

Я также вставляю данные, полученные партиями из родительского контейнера космоса. Я могу получить его, но процесс ввода данных идет слишком медленно. Я думаю, он обновляет предыдущий пакет каждую итерацию. Есть идеи, как я могу быстрее накачать эти данные?

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 

            }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...