title: The specified container does not exist
body: <p>Am stuck with this error <code>The specified container does not exist.</code></p>
  
  <p>let me explain,</p>
  
  <pre><code>CloudBlobClient blobStorage = GetBlobStorage("upload");
  CloudBlockBlob blob = BlobPropertySetting(blobStorage, Guid.NewGuid().ToString().ToLower() + Path.GetExtension(file.FileName));
  blob.UploadFromStream(file.InputStream);
  
  public static CloudBlobClient GetBlobStorage(string cloudBlobContainserName)
      {
          CloudBlobClient blobStorage;
          try
          {
              var storageAccount = CloudStorageAccount.FromConfigurationSetting("StorageConnectionString");
              blobStorage = storageAccount.CreateCloudBlobClient();
              CloudBlobContainer container = blobStorage.GetContainerReference(cloudBlobContainserName); 
              container.CreateIfNotExist();
              var permissions = container.GetPermissions();
              permissions.PublicAccess = BlobContainerPublicAccessType.Container;
              container.SetPermissions(permissions);
          }
          catch (Exception ex)
          {
              Logger.LogError(Log4NetLogger.Category.Exception, "Error in : BlobHandler.GetBlobStorage :&gt;&gt; Exception message: " + ex.Message);
              throw;
          }
          return blobStorage;
      }
      public static CloudBlockBlob BlobPropertySetting(CloudBlobClient cloudBlobClientReferenceName, string blobContentName)
      {
          CloudBlockBlob blob = cloudBlobClientReferenceName.GetBlockBlobReference(blobContentName);
  
  
          return blob;
      }
  </code></pre>
  
  <p>and my <code>StorageConnectionString</code> is </p>
  
  <pre><code>      &lt;Setting name="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=duw;AccountKey=bla bla" /&gt;
  </code></pre>
  
  <p>container 'upload' and the storage account 'duw' exist.</p>
  
  <p>executing <code>blob.UploadFromStream(file.InputStream);</code> statement causes the error.</p>
  
  <p>stack trace :</p>
  
  <blockquote>
    <p>at Microsoft.WindowsAzure.StorageClient.Tasks.Task<code>1.get_Result()
       at Microsoft.WindowsAzure.StorageClient.Tasks.Task</code>1.ExecuteAndWait()
       at Microsoft.WindowsAzure.StorageClient.TaskImplHelper.ExecuteImpl(Func`1 impl)
       at Microsoft.WindowsAzure.StorageClient.CloudBlob.UploadFromStream(Stream source, BlobRequestOptions options)
       at Microsoft.WindowsAzure.StorageClient.CloudBlob.UploadFromStream(Stream source)
       at DAL.Handlers.BlobHandler.CreateAd(HttpPostedFileBase file, Advertisement model) in D:\DU Server\trunk\Du Server\DAL\Handlers\BlobHandler.cs:line 151</p>
  </blockquote>
  
  <p>inner exception:</p>
  
  <p><code>{"The remote server returned an error: (404) Not Found."}</code></p>
  
  <p>can any body help me to sort this out.</p>