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.

Container.CreateIfNotExist throws exception if container exists

See original GitHub issue

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:

 //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:closed
  • Created 11 years ago
  • Reactions:8
  • Comments:50 (4 by maintainers)

github_iconTop GitHub Comments

43reactions
BrainSlugs83commented, Jun 3, 2018

It’s ridiculous that there’s a method named CreateIfNotExists that is supposed to throw if the container already exists. – That’s what the regular Create should do. – additionally, the exception that comes back has the IsRetryable boolean set to true – even though, no matter how many retries you do, it will never succeed. 😦

35reactions
sapienscommented, Feb 13, 2015

2.5 years later and they still have this bug. Just wow…

Read more comments on GitHub >

github_iconTop 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 >

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