2017-01-28 24 views
0

我试图使用PowerShell删除Azure存储目录中删除Azure存储目录: -无法通过PowerShell的

# 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 

因此,路径非常多。我不确定它会如何期待。

回答

1

Remove-AzureStorageDirectory cmdlet来共享名路径参数能够按预期删除路径特定的文件夹。

我唯一能够重现完全相同的错误信息的方式就是我故意使用错误的父文件夹,它是存储文件共享下的根文件夹。

确保您的存储文件共享下的父文件夹确实是“mycontainer”。

注:与Azure中的PowerShell 3.4.0(一月2017)

更新1测试:

基于在评论中提供的网址(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} 

注意所有的斑:删除你的代码上面文件共享相关的,因为他们是不相关的

+0

基本上'mycontainer'是我的容器。所以我不确定它是否应该成为路径的一部分。但是这个命令没有别的办法知道我的容器名是什么。我尝试在一个阶段跳过容器名称,直接使用像mydir/dir1这样的纯文件夹路径,但得到了相同的错误。你能不能在这里提供你的例子,你可以运行无错误 – Dhiraj

+0

你能发布隐藏敏感信息的完整路径吗? – juvchan

+0

https://mystorageaccount.blob.core.windows.net:443/mycontainer/mydir/dir1/ – Dhiraj