繁体   English   中英

无法通过Powershell删除Azure存储目录

[英]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

因此,路径非常存在。 我不知道会是什么期望。

具有ShareNamePath参数的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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM