【发布时间】:2020-02-28 09:30:11
【问题描述】:
我正在使用 powershell 对 Azure 表进行批量插入。使用最新的 Az 模块,而不是 AzureRm。
$context = New-AzStorageContext $storageAccountName -StorageAccountKey $storageAccountKey
$table = (Get-AzStorageTable –Name myTable –Context $context)
foreach($item in $items){
[Microsoft.WindowsAzure.Storage.Table.TableBatchOperation]$batchOperation = New-Object -TypeName Microsoft.WindowsAzure.Storage.Table.TableBatchOperation
$entity = New-Object -TypeName Microsoft.WindowsAzure.Storage.Table.DynamicTableEntity -ArgumentList $partitionKey, $rowKey
$entity.Properties.Add("ID", $id)
$batchOperation.InsertOrReplace($entity)
}
if ($batchOperation.Count -ne 0) {
$table.CloudTable.ExecuteBatch($batchOperation)
}
但我得到的错误是:
Cannot find an overload for "ExecuteBatch" and the argument count: "1"
“ExecuteBatch”这个方法只能在旧的 AzureRm 模块中使用吗?
【问题讨论】:
标签: powershell azure-table-storage