Container.CreateIfNotExist throws exception if container exists
See original GitHub issueWe are trying to create a container reference with the new 1.7.1 SDK but when the container exists it will throw an exception:
//Get a reference to the container for which shared access signature will be created.
CloudBlobContainer container = blobClient.GetContainerReference(containerName);
// create the container if not exists
container.CreateIfNotExist();
This is the exception:
Microsoft.WindowsAzure.StorageClient.StorageClientException was unhandled by user code
Message=The specified container already exists.
Source=Microsoft.WindowsAzure.StorageClient
StackTrace:
at Microsoft.WindowsAzure.StorageClient.EventHelper.ProcessWebResponse(WebRequest req, IAsyncResult asyncResult, EventHandler`1 handler, Object sender) in C:\Users\deisenberg\azure-sdk-for-net\microsoft-azure-api\StorageClient\EventHelper.cs:line 84
at Microsoft.WindowsAzure.StorageClient.CloudBlobClient.EndGetResponse(IAsyncResult asyncresult, WebRequest req) in C:\Users\deisenberg\azure-sdk-for-net\microsoft-azure-api\StorageClient\CloudBlobClient.cs:line 819
at Microsoft.WindowsAzure.StorageClient.Tasks.WebRequestExtensions.<>c__DisplayClass1.<GetResponseAsync>b__0(IAsyncResult asyncresult) in C:\Users\deisenberg\azure-sdk-for-net\microsoft-azure-api\StorageClient\Tasks\WebRequestExtensions.cs:line 103
at Microsoft.WindowsAzure.StorageClient.Tasks.APMTask`1.OnEnd(IAsyncResult ar) in C:\Users\deisenberg\azure-sdk-for-net\microsoft-azure-api\StorageClient\Tasks\APMTask.cs:line 162
InnerException: System.Net.WebException
Message=The remote server returned an error: (409) Conflict.
Source=System
StackTrace:
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at Microsoft.WindowsAzure.StorageClient.EventHelper.ProcessWebResponse(WebRequest req, IAsyncResult asyncResult, EventHandler`1 handler, Object sender) in C:\Users\deisenberg\azure-sdk-for-net\microsoft-azure-api\StorageClient\EventHelper.cs:line 77
InnerException:
Issue Analytics
- State:
- Created 11 years ago
- Reactions:8
- Comments:50 (4 by maintainers)
Top Results From Across the Web
Azure Blob Storage throws exception when creating a new ...
'The specified container already exists. I verify in my Azure environment that no containers exist prior to running this code. While searching ...
Read more >BlobContainerClient.CreateIfNotExists Method
If the container already exists, null . Remarks. A RequestFailedException will be thrown if a failure occurs. Applies to. Product, Versions ...
Read more >CreateIfNotExists error 400 - Microsoft Q&A
The call to CloudBlobClient.GetContainerReference had too much info in it and simply needed to be trimmed down to nothing but the actual container...
Read more >CloudBlobContainer.createIfNotExists - Java
Creates the container if it does not exist. * * @return <code>true</code> if the container did not already exist and was created; otherwise, ......
Read more >What causes “specified container does not exist” error ...
After calling GetContainerReference, container.CreateIfNotExist() was called to ensure the container was there. No errors were thrown.
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
It’s ridiculous that there’s a method named
CreateIfNotExists
that is supposed to throw if the container already exists. – That’s what the regularCreate
should do. – additionally, the exception that comes back has theIsRetryable
boolean set to true – even though, no matter how many retries you do, it will never succeed. 😦2.5 years later and they still have this bug. Just wow…