Azure表存储:用于为现有表填充新列的脚本 [英] Azure Table Storage: a script to populate new column for existing tables
本文介绍了Azure表存储:用于为现有表填充新列的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的Azure表存储中有一些表,需要部署脚本以使用所有表的空数据填充新列.
I have some tables in my Azure Table Storage and need to deploy a script to populate a new column with empty data for all of them.
我知道可以通过PowerShell进行某些管理,但是我找不到有关如何执行此任务的任何相关示例或文档.
I know that some management could be done via PowerShell, but I was unable to find any relevant example or documentation on how to perform this task.
任何帮助将不胜感激.
推荐答案
关于PowerShell脚本,请参考以下代码:
Regarding the PowerShell script, please refer to the following code:
Install-Module -Name AzTable
$groupName=""
$StorageAccountName = ""
$StorageAccountKey = ""
$vaule=" "
$context = New-AzStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey
$tables = Get-AzStorageTable -Context $context
Foreach($table in $tables){
$table = Get-AzTableTable -storageAccountName $StorageAccountName -resourceGroup $groupName="" -TableName
$entities=Get-AzTableRow -Table $table
ForEach($e in $entities){
$entity = New-Object Microsoft.Azure.Cosmos.Table.DynamicTableEntity($e.PartitionKey,$e.RowKey)
$entity.Properties.Add("Name", $vaue)
$table.Execute([Microsoft.Azure.Cosmos.Table.TableOperation]::InsertOrMerge($entity))
Get-AzTableRow -Table $table -PartitionKey $e.PartitionKey -RowKey $e.RowKey
}
}
这篇关于Azure表存储:用于为现有表填充新列的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文