![](/img/trans.png)
[英]Not able to delete directory from Azure Storage container by Databricks notebook
[英]Not able to delete Azure Storage Directory through Powershell
我正在嘗試使用Powershell刪除Azure存儲目錄:-
# the Context is already set correctly, not showing it here though
if( $myshare -eq $null )
{
$myshare=New-AzureStorageShare -Name "share" -Context $context
}
Remove-AzureStorageDirectory -ShareName "share" -Path "mycontainer/mydir/dir1" -Context $context -Confirm:$false
我收到以下錯誤:
Remove-AzureStorageDirectory : The remote server returned an error: (404) Not Found. HTTP
Status Code: 404 - HTTP Error Message: The specified parent path does not exist.
At C:\test.ps1:21 char:1
+ Remove-AzureStorageDirectory -ShareName "share" -Path "mycontainer/my ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Remove-AzureStorageDirectory], StorageException
+ FullyQualifiedErrorId : StorageException,Microsoft.WindowsAzure.Commands.Storage.File.Cmd
let.RemoveAzureStorageDirectory
這就是我要刪除的文件夾(dir1)在我的存儲中的存在方式:-
mycontainer/mydir/dir1
因此,路徑非常存在。 我不知道會是什么期望。
具有ShareName和Path參數的Remove-AzureStorageDirectory
cmdlet能夠按預期刪除路徑中的特定文件夾。
當我故意使用錯誤的父文件夾 ,即存儲文件共享下的根文件夾時,我唯一能夠再現與您完全相同的錯誤消息的方法。
確保存儲文件共享下的父文件夾確實是“ mycontainer ”。
注意:已使用Azure PowerShell 3.4.0測試(2017年1月)
更新1:
根據注釋中提供的URL( https://mystorageaccount.blob.core.windows.net/mycontainer/mydir/dir1/ ),用戶的“文件夾”位於“存儲Blob”下而不是“文件共享”下,這顯然是為什么上面的cmdlet不起作用。
更新2
下面的PowerShell命令將刪除“ dir1”下的所有斑點
Get-AzureStorageBlob -Container "mycontainer" -blob "*dir1/*" -Context $context | ForEach-Object {Remove-AzureStorageBlob -Blob $_.Name -Container "mycontainer" -Context $context}
注意:刪除上面與文件共享相關的代碼,因為它們不相關
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.