none
Container.ListBlobs error

    Question

  • I'm getting the following error while trying to iterate through a list of blobs: "The specified resource does not exist." StorageClientException.

    This is what I have.

          CloudBlobContainer container = AzureClient.GetContainerReference(GetJobContainer(JobID) + "/");
    
          IEnumerable<IListBlobItem> Blobs = container.ListBlobs();
    
          List<Uri> ReturnValue = new List<Uri>();
    
          foreach (var BlobItem in Blobs)
          {
    
            ReturnValue.Add(BlobItem.Uri);
    
          }
    

    It fails at: foreach (var BlobItem in Blobs). There is one container called "testcontainer" and a single blob within called helloworld.txt.

    I'm using the development storage. Both the container and the blob upload were generated by the Azure MMC. The file also shows up within the VS2010 Azure pane. What am I doing wrong here?


    Owner, Quilnet Solutions
    Friday, February 11, 2011 9:20 PM

Answers

All replies

  • I'm not sure why you have a "/" in the container name since the following is documented:

    -- Container names must start with a letter or number, and can contain only letters, numbers, and the dash (-) character.

    The following is more or less taken from a post on blobs I did a while back:

    protected void GetBlobs(CloudStorageAccount cloudStorageAccount, String containerName)
    {
      CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
    
      CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference(containerName);
      IEnumerable<IListBlobItem> blobList = cloudBlobContainer.ListBlobs();
      foreach (IListBlobItem item in blobList)
      {
        Uri uri = item.Uri;
      }
    }
    
    


    Cerebrata's Cloud Storage Studio is a really useful tool for looking at Azure Storage.

    Friday, February 11, 2011 9:44 PM
    Answerer
  • I added the '/' at the end because if I didn't I was getting an error on the container saying that it cannot find account information in the uri. Adding the '/' was the only way to get rid of the error.
    Owner, Quilnet Solutions
    Friday, February 11, 2011 9:50 PM
  • Hi,

    Have you tried hardcoding the blob container name? i.e. replacing:

    CloudBlobContainer container = AzureClient.GetContainerReference(GetJobContainer(JobID) + "/");

    with something like:

    CloudBlobContainer container = AzureClient.GetContainerReference("http://127.0.0.1:10000/testcontainer");

    Hope this helps.

    Thanks

    Gaurav Mantri

    Cerebrata Software

    http://www.cerebrata.com

     

    Saturday, February 12, 2011 4:17 PM
  • If the container is called "testcontainer," then the way to get the container reference is: AzureClient.GetContainerReference("testcontainer").  There shouldn't be any "http://" in there, no slashes at all, etc.

    For the original poster, I assume that either GetJobContainer(JobID) is not returning the string "testcontainer," or AzureClient hasn't been properly constructed.

    Saturday, February 12, 2011 8:18 PM
  • If the container is called "testcontainer," then the way to get the container reference is: AzureClient.GetContainerReference("testcontainer").  There shouldn't be any "http://" in there, no slashes at all, etc.

    For the original poster, I assume that either GetJobContainer(JobID) is not returning the string "testcontainer," or AzureClient hasn't been properly constructed.


    Yes, GetJobContainer(JobID) returns an absolute string of 'testcontainer'. It does not include the base address.
    Owner, Quilnet Solutions
    Saturday, February 12, 2011 10:46 PM
  • Hi,

    Have you tried hardcoding the blob container name? i.e. replacing:

    CloudBlobContainer container = AzureClient.GetContainerReference(GetJobContainer(JobID) + "/");

    with something like:

    CloudBlobContainer container = AzureClient.GetContainerReference("http://127.0.0.1:10000/testcontainer");

    Hope this helps.

    Thanks

    Gaurav Mantri

    Cerebrata Software

    http://www.cerebrata.com

     


    Yes I have tried coding the blob container directly. I have not tried doing a GetContainerReference() with the base address. I will try this and let you guys know.
    Owner, Quilnet Solutions
    Saturday, February 12, 2011 10:47 PM
  • When I come across problems with Azure Storage the second thing I do is test against Cloud Storage. For one, this makes the first thing I try (Fiddler) much easier, and for another there are some edge case differences in behavior. There is clearly something funky going on with the apparent need for the "/" which is not a valid character. Moving to cloud storage would take out of the picture any possible funkiness to do with the construction of URLs. (It would also take out of the picture the existing container and blob).

    I wonder if the cloud storage account is created correctly.

    I suggest you use Fiddler to trap the request and response strings - and post them here.

     

    Saturday, February 12, 2011 11:33 PM
    Answerer
  • I thought about that, using the Live Azure Cloud instead of the dev storage. I submitted a request to get cloud storage operable for this project, I'm still waiting to hear back.

    I also requested a Dev box with fiddler so if I can get that authorized, I'll be able to do what you suggested if the cloud storage determines the same result.

    I'll report back once I get my requests approved and get this tested.


    Owner, Quilnet Solutions
    Saturday, February 12, 2011 11:57 PM
  • I figured out what was going on.

    My base address was http://127.0.0.1:10000, and I was calling the container as http://127.0.0.1:10000/testcontainer. This is wrong.

    It should have been http://127.0.0.1:10000/devstoreaccount1, and calling the container as http://127.0.0.1:10000/devstoreaccount1/testcontainer.

    Once I switched this I was able to drop the extra "/" and get the ListBlob function to work.


    Owner, Quilnet Solutions
    • Marked as answer by Quilnux Monday, February 14, 2011 9:00 PM
    Monday, February 14, 2011 9:00 PM