简体   繁体   English

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

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

相关问题 无法从 Databricks 笔记本的 Azure 存储容器中删除目录 - Not able to delete directory from Azure Storage container by Databricks notebook 无法通过 powershell 脚本删除 azure 中的测试用例 - not able to delete test cases in azure devops through powershell scripts 无法从 Azure 存储帐户中删除 blob - Azure Function (Java) - Not able to delete blob from Azure storage Account - Azure Function (Java) 无法删除我的主 AD 目录下的 Azure AD 目录 - Not able to delete Azure AD directory under my primary AD directory 使用PowerShell从3个月以上的Azure存储帐户中删除表 - Delete tables from azure storage account older than 3 months with PowerShell 使用 powershell 脚本删除 azure 文件共享存储中的空文件夹 - Delete empty folders in azure file share storage using powershell script 删除 Azure 存储帐户中的 blob,使用 powershell 的最新版本除外 - Delete blobs in Azure storage account except the lastest version using powershell 通过Powershell将实体从XML文件上传到Azure存储表 - Uploading entities to azure storage table from XML file through powershell 在新门户中通过powershell创建azure存储容器 - Create azure storage container through powershell in new portal 批量删除是在 Azure 存储中执行目录删除的更好方法吗? - Is batch deletion a better way to perform a directory delete in Azure storage?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM