none
ContainerNotFound Error

    Question

  • Hi,

     

    I am creating an Azure storage blob container with its name as a GUID (lower case).

    account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
    
    nameOfContainer = containerName.ToLower();
    
    CloudBlobClient client = account.CreateCloudBlobClient();
    
    container = client.GetContainerReference(nameOfContainer);
    
    container.CreateIfNotExist();
    
    
    
    //set public access to the container
    
    var permission = container.GetPermissions();
    
    permission.PublicAccess = BlobContainerPublicAccessType.Container;itlinfosys
    
    container.SetPermissions(permission);
    
    
    
    
    and then creating blob as below
    string id = Guid.NewGuid().ToString().ToLower();
    
    string blobName = id + ":" + blobName + ".zip";
    
    
    CloudBlobClient client = account.CreateCloudBlobClient();
    
         
    
    CloudBlob blob = container.GetBlobReference(blobName);
    
    var metadata = new NameValueCollection();
    
    metadata["Id"] = id;
    
    metadata["BlobName"] = String.IsNullOrEmpty(blobName) ? "unknown" : blobName;
    
    metadata["Description"] = String.IsNullOrEmpty(description) ? "unknown" : description;
    
    metadata["Tags"] = String.IsNullOrEmpty(tags) ? "unknown" : tags;     
    
    
    
    // Add and commit metadata to blob
    
    blob.Metadata.Add(metadata);
    
         
    
    if (orStream != null)
    
     blob.UploadFromStream(orStream);
    
    blobURI = blob.Uri.ToString();
    
    
    
    

    At times (almost 50%), I get the error – “ContainerNotFound. The specified container does not exist.”

    Inner Ex.- “The remote server returned an error: (404) Not Found.”

    Stack Trace- “at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()

     

       at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait()

     

       at Microsoft.WindowsAzure.StorageClient.CloudBlob.UploadFromStream(Stream source, BlobRequestOptions options)”

     

    This error is not consistent. It is thrown sometimes and could not get any specific condition too when it will throw this error. I checked the Azure storage account through Azure storage explorer and it exists there.

     

    I put the trace on values of below which does not come properly in case of this error.

     

    container.Name = 3683ae5c-912a-4351-ac1b-e237386e5878

     

    blob.Uri = http://scmtesting1.blob.core.windows.net/GeneratedSolution.zip  (in case of no error it comes like http://scmtesting1.blob.core.windows.net/3683ae5c-912a-4351-ac1b-e237386e5878/7a251787-33f1-41cb-9b6b-a53a59c7d88c:GeneratedSolution.zip)

     

    blob.Container.Name = GeneratedSolution.zip (in case of no error it comes like - 3683ae5c-912a-4351-ac1b-e237386e5878)

     

    blob.Container.Uri = http://scmtesting1.blob.core.windows.net/GeneratedSolution.zip (in case of no error it comes like - http://scmtesting1.blob.core.windows.net/3683ae5c-912a-4351-ac1b-e237386e5878 )

     

    Any suggestion in this would help me.

     

    Thanks,

    Divya

    Tuesday, December 21, 2010 8:38 AM

Answers

  • The following is documented for blob names:

    -- A blob name can contain any combination of characters, but reserved URL characters must be properly escaped.

    I would probably not use the colon character in a blob name.

    Using Fiddler to verify precisely what is sent over the wire to Azure Storage can often provide good information in cases like this.

    Tuesday, December 21, 2010 9:48 AM
    Answerer