Reputation: 61
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.
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.
Any help would be appreciated.
Upvotes: 1
Views: 2528
Reputation: 23111
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
}
}
Upvotes: 2
Reputation: 136136
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.
Basically Azure Table is a key/value pair store so it can't really have columns (key) with no data (value) in it. This is applicable to all supported data types with an exception of String
data type where you can store an empty string (it's still not null) as value for a key.
As to how you go about doing it, here're the steps you can follow:
PartitionKey
and RowKey
attributes.String
and set the value of that attribute to empty string (""
).Merge Entity
operation on those entities. This will ensure that only the new attribute will get added. All other existing attributes in that entity will remain unchanged.Unfortunately I am not too familiar with PowerShell to provide exact syntax. But this should give you enough idea to get going.
Upvotes: 1