删除Azure存储表条目

问题描述:

我在Azure表存储中存在一些现有数据。因此,当我部署csv文件时,最新的更改正在部署,但存在于Azure表存储中的数据不会覆盖或旧数据不会被删除。例如:我在azure存储中存在3行数据,当我部署有5行的csv文件时,5行数据正在部署,3行的旧数据没有删除。应该覆盖但不会发生。请帮帮我。 - 订阅详情:删除Azure存储表条目

$subscriptionName = "Tech Enabled Solutions" 
     $resourceGroupName = "abc" 
     $storageAccountName = "defghi" 
     $location = "North Central US" 
     $tableName = "TestTable" 
     # Get the storage key for the storage account 
     $storageAccountKey = "12345678990" 
    # Get a storage context 
     $ctx = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey 
     $table = Get-AzureStorageTable -Name $tableName -Context $ctx -ErrorAction Ignore 
     #If the table exists, start deleting its entities. 
     if ($table -ne $null) 
     { 
     $table=Get-AzureStorageTableRowAll -table $table | Remove-AzureStorageTableRow -table $table -Context $ctx 
     } 
+0

误差上面的脚本:2017-10-17T13:11:33.6495612Z ## [错误]获取-AzureStorageTableRowAll:术语“GET -AzureStorageTableRowAll'不被识别为cmdlet的名称, 函数,脚本文件或可操作程序。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。 在D:\ a \ 1 \ s \ DeploymentScripts \ deleteentity.ps1:20 char:11 $ table = Get-AzureStorageTableRowAll --table $ table | Remove-AzureSto ... + + CategoryInfo:ObjectNotFound(GetAzureStorageTableRowAll:String)[],CommandNotFoundException –

一开始AzureStorageTableRowAll命令在AzureRmStorageTable模块,所以调用命令之前安装它。

这个命令添加到您的脚本来安装该模块:

Install-PackageProvider -Name NuGet -Force -Scope CurrentUser 
Install-Module -Name AzureRmStorageTable -Force -Verbose -Scope CurrentUser 
+0

令人敬畏的Bro.Really欣赏again.It现在工作。现在,我可以部署一个CSV文件的数据,但如果我想部署倍数csv文件,那么我怎样才能通过脚本执行。 –

+0

我的假设是,如果我可以将文件作为参数传递给脚本,它将读取该文件,并可以将该特定文件的数据插入和删除到azure存储中。但是目前我正在使用此命令插入数据在Power Shell脚本中... $ csv = Import-CSV“d:\ a \ 1 \ s \ DeploymentScripts \ TestTable.csv”当前按照它的测试脚本testtable.csv –

+0

如果我想传递不同的文件, testtable2.csv到powershell脚本中,我不能编写第二个脚本并保持VSTS回购权,因为我需要将很多csv文件部署到Azure storage.so中,在脚本运行时如何使用一个脚本传递不同的文件脚本,我目前正在运行。我如何实现该脚本以及如何传递参数。 –