i need example or tutorials on use of azure table storage in powershell. know how create tables, insert entities, , display entities. but, can give me direction towards update case. how update existing entity in table in powershell? how check/access particular column of entity in table in powershell?
script add entity:
function insertrow($table, [string]$partitionkey, [string]$rowkey, [int]$intvalue) { $entity = new-object "microsoft.windowsazure.storage.table.dynamictableentity" $partitionkey, $rowkey $entity.properties.add("intvalue", $intvalue) $result = $table.cloudtable.execute([microsoft.windowsazure.storage.table.tableoperation]::insert($entity)) } $storageaccountname = "storagename" $storageaccountkey = "storagekey" $context = new-azurestoragecontext -storageaccountname $storageaccountname -storageaccountkey $storageaccountkey $tablename = "test" $table = get-azurestoragetable $tablename -context $context -erroraction ignore if ($table -eq $null) { new-azurestoragetable $tablename -context $context } ($p = 1; $p -le 1; $p++) { ($r = 1; $r -le 1; $r++) { insertrow $table "p$p" "r$r" $r } }
script display entities in table:
$query = new-object microsoft.windowsazure.storage.table.tablequery #define columns select. $list = new-object system.collections.generic.list[string] $list.add("rowkey") $list.add("intvalue") #set query details. $query.selectcolumns = $list $query.takecount = 20 #execute query. $entities = $table.cloudtable.executequery($query) #display entity properties table format. $entities | format-table partitionkey, rowkey, @{ label = "intvalue"; expression={$_.properties["intvalue"].int32value}} -autosize
i need commands update particular entity. help??
got it. change value of entity doing $entity.properties["intvalue"].int32value
, use command update entity:
$result = $table.cloudtable.execute([microsoft.windowsazure.storage.table.tableoperation]::insertorreplace($entity))
$query.filterstring
can used specific entities table.
Comments
Post a Comment