microsoft / Partner-Center-Storefront

A storefront that enables reseller partners to onboard customers and place orders for these customers.
MIT License
20 stars 55 forks source link

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

Open preuday opened 3 years ago

preuday commented 3 years ago

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.