Is there an API call I can make to Azure Storage to tell if my container has been deleted?

你离开我真会死。 提交于 2019-12-01 13:07:23

问题


I want to clear a storage account then "restore" to it using AzCopy.

I clear last nights storage using

$ctx = New-AzureStorageContext -StorageAccountName $storage -StorageAccountKey $key Get-AzureStorageContainer a* -Context $ctx | Remove-AzureStorageContainer -Force

And then use AzCopy but get;

The remote server returned an error: (409) Conflict. The specified container is being deleted. Try operation later.

I don't want to loop, trying to create the storage again. How can I wait for the Remove operation to complete?

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


回答1:


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

Unfortunately there's none. You just have to keep on trying.

Based on the documentation here: 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.

Though they are saying 30 seconds but depending on the number of blobs in the container, it may take even longer than that.

Other alternative would be to delete all blobs individually instead of deleting the container. However because each delete is a separate network call, the process may run for a longer duration (and is prone to network failures) but it would guarantee you that when you start using AzCopy, the container will be empty.




回答2:


Isn't the error message enough to give you the same behavior. You can write that API yourself. Or I'm missing something?

"The specified container is being deleted. Try operation later."



来源:https://stackoverflow.com/questions/34747994/is-there-an-api-call-i-can-make-to-azure-storage-to-tell-if-my-container-has-bee

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!