question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BlobContainerClient.CreateIfNotExistsAsync throws exception if container exists

See original GitHub issue

Library name and version

Azure.Storage.Blobs, Version=12.10.0.0

Describe the bug

We are seeing the below error when using Container.CreateIfNotExistsAsync. Please note that the issue is intermittent.

Azure.RequestFailedException: The specified container already exists.
RequestId:8798dabf-201e-0060-0a49-60afb2000000
Time:2022-05-05T06:26:54.0405240Z
Status: 409 (The specified container already exists.)
ErrorCode: ContainerAlreadyExists

Please note that the container is never getting deleted.

Expected behavior

The Exception should not be thrown

Actual behavior

The described exception is thrown.

Reproduction Steps

Use BlobContainerClient.CreateIfNotExistsAsync, we can see the exception in some cases.

Environment

Azure App Service .Net core 3.1

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:23 (8 by maintainers)

github_iconTop GitHub Comments

10reactions
LenaVinogradovcommented, Jan 27, 2023

We are affected by the same issue. The fact that exception is thrown when container exists and logged to AppInsights enquire extra cost on our AppInsights instances. This is internal exception and should not be logged to appInsights. Suggested workaround of suppressing all 409 is not acceptable as it hides all of them leading to missing critical information for other cases when 409 is not a results of Blob.CreateIfNotExist.

@RakeshMohanMSFT , many people on this thread clearly consider it as a bug. What’s required in order for the product team to treat is as a bug?

5reactions
Sandeep7OnShellcommented, May 6, 2022

Hi @RakeshMohanMSFT By design everything is alright. The issue is when using BlobContainerClient.CreateIfNotExists, it says “Azure.RequestFailedException: The specified container already exists.” whereas it should just be silent and shouldn’t touch the container when it’s already there.

Note: 409 is not fatal, its just an information/indicator - Application insights flags this as an error/failure. Also, further process seems to be in problem when this happens.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Container.CreateIfNotExist throws exception if ...
We are trying to create a container reference with the new 1.7.1 SDK but when the container exists it will throw an exception:....
Read more >
Alternative for BlobContainerClient.CreateIfNotExistsAsync ...
One could ask why an exception is thrown instead of checking the status code, but the code doesn't throw a 409 if a...
Read more >
BlobContainerClient.CreateIfNotExistsAsync Method
A Response<T> describing the newly created container. Remarks. A RequestFailedException will be thrown if a failure occurs. Applies to. Product, Versions ...
Read more >
Create a blob container with .NET - Azure Storage
CreateAsync. These methods throw an exception if a container with the same name already exists. Containers are created immediately beneath the ...
Read more >
Class BlobContainerClient | Azure SDK for Net
A Response<T> describing the newly created container. Remarks. A RequestFailedException will be thrown if a failure occurs. CreateIfNotExistsAsync( ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found