0

Is there something similar to the AzureTableEntity module that can be used to insert batches of data in an Azure Table Storage.

Gudrun
  • 3
  • 1

1 Answers1

0

Below code will help you in executing the batch insert operation

Connect-AzAccount

$ResourceGroupName = "testfun06"
$StorageAccountName="testfun06bf01"
$TableName="People"

$keys=Get-AzStorageAccountKey -ResourceGroupName $ResourceGroupName -Name $StorageAccountName

$ctx = New-AzStorageContext -StorageAccountName $StorageAccountName  -StorageAccountKey $keys[0].Value
$table = Get-AzStorageTable  -Name $TableName -Context $ctx

$e = New-Object Microsoft.Azure.Cosmos.Table.DynamicTableEntity("Jim","test")
$e1 = New-Object Microsoft.Azure.Cosmos.Table.DynamicTableEntity("Jim","test1")
[Microsoft.Azure.Cosmos.Table.TableBatchOperation] $batchOperation = New-Object -TypeName Microsoft.Azure.Cosmos.Table.TableBatchOperation
$batchOperation.InsertOrMerge($e)
$batchOperation.InsertOrMerge($e1)

$table.CloudTable.ExecuteBatch($batchOperation)

enter image description here

For further information check the SO1 and SO2 threads.

SaiSakethGuduru
  • 2,218
  • 1
  • 5
  • 15