azure-sdk-for-net: BlobContainerClient.CreateIfNotExistsAsync throws exception if container exists
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
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 3
- Comments: 23 (8 by maintainers)
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.
@Sandeep7OnShell Since you mentioned AppInsights earlier I suggested that.
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
But I understand your concern, will keep our engineering team informed to consider this requirement in future releases.
@RakeshMohanMSFT Surprised that it’s giving a message via an exception and not handled gracefully.
Any news to it? It stills floods the AI logs 😦
@RakeshMohanMSFT Is there somewhere that the telemetry “Type” names are specified so we know what specific entries to exclude/update in our initializers? We wouldn’t want to exclude ALL 409s for obvious reasons, just the ones from Blob storage would solve this problem. I can’t find a list of the names that are used for each SDK or anything similar anywhere?
@RakeshMohanMSFT @jsquire
Thank you for understanding the concern, please tag the necessary handles here and keep this thread posted with the latest information.
BlobContainerClient.CreateIfNotExists internally will internally query the available containers to decide to create a container or not other than that it does not impact any existing container.
With the above statement, it should not throw the exception that says “Azure.RequestFailedException: The specified container already exists.” We always have the container, not getting deleted ever.
@Sandeep7OnShell BlobContainerClient.CreateIfNotExists internally will internally query the available containers to decide to create a container or not other than that it does not impact any existing container.
As far as your application insights issue is concerned please go through this article to avoid any unnecessary noise. https://docs.microsoft.com/en-us/azure/azure-monitor/app/api-filtering-sampling#addmodify-properties-itelemetryinitializer