无法通过 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/),用户的 "folder" 在 Storage Blob 而不是 File Share 下,这显然是上面的 cmdlet 不是的原因在职的。

更新 2

下面的 PowerShell 命令将删除 "dir1"

下的所有 blob
Get-AzureStorageBlob -Container "mycontainer" -blob "*dir1/*" -Context $context | ForEach-Object {Remove-AzureStorageBlob -Blob $_.Name -Container "mycontainer" -Context $context}

注意:删除上面与文件共享相关的代码,因为它们不相关