How to use Powershell to update property of an entity in Azure Table Storage to null?

蹲街弑〆低调 提交于 2020-01-16 18:04:07

问题


Lets say I have retrieved an entity from my table. I want to set one of the property to null. How can I do it? This is what I did:

 $myData.PropertyOne = $null
 $myData | Update-AzureStorageTableRow -table $destStorageTable 

But I got error:

Exception calling "Execute" with "1" argument(s): "Object reference not set to an instance of an object." At C:\Program Files\WindowsPowerShell\Modules\AzureRmStorageTable\1.0.0.21\AzureRmStorageTableCoreHelper.psm1:629 char:13 + ... return ($table.CloudTable.Execute((invoke-expression "[Microsoft ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : StorageException


回答1:


How can I do it?

The problem is that because azure table storage does not have a schema, the null column actually doesn't exist. You could do something like store an empty string if you really have to.

 $myData.PropertyOne = ""
 $myData | Update-AzureStorageTableRow -table $destStorageTable 




回答2:


I think you need to remove the column -

$myData.psobject.Properties.Remove('PropertyOne')
$myData | Update-AzureStorageTableRow -table $destStorageTable 


来源:https://stackoverflow.com/questions/48339835/how-to-use-powershell-to-update-property-of-an-entity-in-azure-table-storage-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!