locked
Azure storage - ListContainers only returning single row RRS feed

  • Question

  • Hello, 

    I have an Azure storage account that has approx. 30 blob containers in it.  I'm trying to get a list of all these containers in a .net 4.5 console app without much luck. 

    var lisfOfContainers = new List<string>();
    
    storageAccount = CloudStorageAccount.Parse(ae.ConnectionString);
    blobClient = storageAccount.CreateCloudBlobClient();
    IEnumerable<CloudBlobContainer> containers = blobClient.ListContainers();
    
    foreach (CloudBlobContainer c in containers)
    {
        lisfOfContainers.Add(c.Uri.Segments[2] != null ? c.Uri.Segments[2].ToString() : string.Empty);
    }
    
    return lisfOfContainers;

    Firstly the call to ListContainers only returns one result, even if I enumerate the result set in debug and secondly, the foreach bombs out on on the array element 2. 

    Does anyone have a working example of how to do this they could share? 

    Thanks


    Saturday, April 28, 2018 2:59 PM

All replies

  • It is where you can post for help.

    https://social.msdn.microsoft.com/forums/azure/en-US/home?category=windowsazureplatform

    Saturday, April 28, 2018 8:28 PM
  • Hi Slartibartfast,

    According to your question is more related to Azure, you need to repost a new thread to Azure Forum  for better support.

    https://social.msdn.microsoft.com/forums/azure/en-US/home?category=windowsazureplatform

    Best Regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, May 3, 2018 5:51 AM