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? 


    Saturday, April 28, 2018 2:59 PM

All replies