BlobContainerClient.CreateIfNotExistsAsync throws exception if container exists
See original GitHub issueLibrary 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:
- Created a year ago
- Reactions:3
- Comments:23 (8 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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?
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.