azure - 我是否可以对 Azure 存储进行 API 调用来判断我的容器是否已被删除?

标签 azure azure-storage azcopy

我想清除存储帐户,然后使用 AzCopy“恢复”它。

我使用清除昨晚的存储

$ctx = New-AzureStorageContext -StorageAccountName $storage -StorageAccountKey $key 获取-AzureStorageContainer a* -Context $ctx |删除-AzureStorageContainer-Force

然后使用AzCopy却得到;

远程服务器返回错误:(409) 冲突。 正在删除指定的容器。稍后尝试操作。

我不想循环,尝试再次创建存储。如何等待删除操作完成?

是否有 Get-AzureStorageContainer 状态? “删除?”

最佳答案

Is there a Get-AzureStorageContainer status? "Deleting?"

不幸的是没有。你只需要继续努力。

基于此处的文档:https://msdn.microsoft.com/en-us/library/azure/dd179408.aspx

When a container is deleted, a container with the same name cannot be created for at least 30 seconds; the container may not be available for more than 30 seconds if the service is still processing the request. While the container is being deleted, attempts to create a container of the same name will fail with status code 409 (Conflict), with the service returning additional error information indicating that the container is being deleted. All other operations, including operations on any blobs under the container, will fail with status code 404 (Not Found) while the container is being deleted.

虽然他们说的是 30 秒,但根据容器中 blob 的数量,可能需要更长的时间。

另一种选择是单独删除所有 blob,而不是删除容器。但是,由于每个删除都是单独的网络调用,因此该过程可能会运行较长的持续时间(并且容易出现网络故障),但它可以保证您开始使用 AzCopy 时,容器将为空。

关于azure - 我是否可以对 Azure 存储进行 API 调用来判断我的容器是否已被删除?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55214640/

相关文章:

javascript - 通过 Azure 存储以 HTML 格式获取 JSON 文件

Azure 搜索 - 在搜索字符串中使用双引号

azure - AzCopy 上传最大连接数

Azure - 通过数据工厂获取 Log Analytics 查询

azure - 如何在 Windows Azure 上设置具有 2 个不同区域的连接虚拟机

c# - 将附件保存在 blob 容器中 - 机器人框架

.net - GetBlobReferenceFromServer 不适用于相对 URI。错误: "Only absolute addresses are permitted"

c# - 使用 Https 的 Azure Blob 存储

Azure Blob 备份

azure - 批量复制/删除容器中的一些blob