Is there an API call I can make to Azure Storage t

2020-03-31 07:08发布

问题:

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."