2017-10-17 208 views
0

我在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 –

回答

0

一開始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中,在腳本運行時如何使用一個腳本傳遞不同的文件腳本,我目前正在運行。我如何實現該腳本以及如何傳遞參數。 –