handle error condition when creating a container that is being deleted (#582)

When users try to create a container immediately after deleting it, Azure will fail saying the deletion is in-progress.

catching ResourceExistsError during create handles this error.
This commit is contained in:
bmc-msft
2021-02-21 20:49:07 -05:00
committed by GitHub
parent feb80ecb54
commit cebb84b9e7

View File

@ -10,7 +10,7 @@ import urllib.parse
from typing import Dict, Optional, Union, cast from typing import Dict, Optional, Union, cast
from azure.common import AzureHttpError, AzureMissingResourceHttpError from azure.common import AzureHttpError, AzureMissingResourceHttpError
from azure.core.exceptions import ResourceNotFoundError from azure.core.exceptions import ResourceExistsError, ResourceNotFoundError
from azure.storage.blob import ( from azure.storage.blob import (
BlobClient, BlobClient,
BlobSasPermissions, BlobSasPermissions,
@ -123,7 +123,9 @@ def create_container(
client = get_blob_service(account).get_container_client(container) client = get_blob_service(account).get_container_client(container)
try: try:
client.create_container(metadata=metadata) client.create_container(metadata=metadata)
except AzureHttpError as err: except (ResourceExistsError, AzureHttpError) as err:
# note: resource exists error happens during creation if the container
# is being deleted
logging.error( logging.error(
( (
"unable to create container. account: %s " "unable to create container. account: %s "