[英]Not able to delete Azure Storage Directory through Powershell
I am trying to delete Azure Storage directory using 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
I am getting the following error:- 我收到以下错误:
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
This is how the folder that I am trying to delete (dir1) exists in my storage:- 这就是我要删除的文件夹(dir1)在我的存储中的存在方式:-
mycontainer/mydir/dir1
So the path very much exists. 因此,路径非常存在。 I am not sure what it's expecting otherwise.
我不知道会是什么期望。
The Remove-AzureStorageDirectory
cmdlet with ShareName and Path parameters is able to remove specific folder in the path as expected. 具有ShareName和Path参数的
Remove-AzureStorageDirectory
cmdlet能够按预期删除路径中的特定文件夹。
The only time I am able to reproduce the exact same error message as you're having is when I purposely use the wrong parent folder , which is the root folder under the storage file share. 当我故意使用错误的父文件夹 ,即存储文件共享下的根文件夹时,我唯一能够再现与您完全相同的错误消息的方法。
Ensure that your parent folder under your storage file share is indeed " mycontainer ". 确保存储文件共享下的父文件夹确实是“ mycontainer ”。
Note: Tested with Azure PowerShell 3.4.0 (January 2017) 注意:已使用Azure PowerShell 3.4.0测试(2017年1月)
Update 1: 更新1:
Based on the URL ( https://mystorageaccount.blob.core.windows.net/mycontainer/mydir/dir1/ ) provided in the comment, the user's "folder" is under Storage Blob instead of File Share, which is obviously why the cmdlet above is not working. 根据注释中提供的URL( https://mystorageaccount.blob.core.windows.net/mycontainer/mydir/dir1/ ),用户的“文件夹”位于“存储Blob”下而不是“文件共享”下,这显然是为什么上面的cmdlet不起作用。
Update 2 更新2
The PowerShell command below will remove all the blobs under the "dir1" 下面的PowerShell命令将删除“ dir1”下的所有斑点
Get-AzureStorageBlob -Container "mycontainer" -blob "*dir1/*" -Context $context | ForEach-Object {Remove-AzureStorageBlob -Blob $_.Name -Container "mycontainer" -Context $context}
Note: Remove your code above related to File Share as they are not relevant 注意:删除上面与文件共享相关的代码,因为它们不相关
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.