Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Usage of CreateAsync() method triggering 409(container already exist) errors resulting unresponsive application #39

Open
preuday opened this issue Jun 25, 2021 · 0 comments

Comments

@preuday
Copy link

preuday commented Jun 25, 2021

Hello Team,

When using the following application "https://github.com/microsoft/Partner-Center-Storefront", noticed container "customerportalassets" being called multiple times and multiple 409(container already exists) errors received on create container operation resulting in an unresponsive application.

From the below code section ,noticed CreateAsync() method

///


/// Returns a cloud BLOB container reference which can be used to manage the public customer portal assets.
///

/// The public customer portal assets BLOB container.
public async Task GetPublicCustomerPortalAssetsBlobContainerAsync()
{
if (publicBlobContainer == null)
{
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
publicBlobContainer = blobClient.GetContainerReference(PublicPortalAssetsBlobContainerName);
}

        if (!await publicBlobContainer.ExistsAsync().ConfigureAwait(false))
        {
            await publicBlobContainer.CreateAsync().ConfigureAwait(false);

            BlobContainerPermissions permissions = await publicBlobContainer.GetPermissionsAsync().ConfigureAwait(false);
            permissions.PublicAccess = BlobContainerPublicAccessType.Blob;

            await publicBlobContainer.SetPermissionsAsync(permissions).ConfigureAwait(false);
        }

        return publicBlobContainer;
    }

As per following document this method will throw error when container already exists. Reference doc : https://docs.microsoft.com/bs-latn-ba/Azure/storage/blobs/storage-blob-container-create?tabs=dotnetv11#create-a-container

 The CreateIfNotExists and CreateIfNotExistsAsync methods return a Boolean value indicating whether the container was created. If a container with the same name already exists, these methods return False to indicate a new container wasn't created. 

could you please confirm if this createAsync() method here could be causing the 409s on container "customerportalassets" , If
not , please share your insights or workaround to avoid these errors from Application end.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant