title: Azure issues listing blobs
body: <p>I am trying to list out and get the blobs in my container from azure blob storage in order to be able to download the file, and send the results via my API. I've followed the instructions microsoft has here: <a href="https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blobs-list?tabs=dotnet" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blobs-list?tabs=dotnet</a></p>
  <p>My file structure for my blobs is {Guid}/images/{Guid}.jpg, where {Guid} is a Guid with the dashes still in place.</p>
  <p>However, neither method actually works. I've tried both with a flat list (which won't work given that I have a hierarchical nesting) :</p>
  <pre><code>        var resultSegment = containerClient.GetBlobsAsync().AsPages();
  
          await foreach(var blobPage in resultSegment)
          {
              foreach(var blobItem in blobPage.Values)
              {
  
                  using(var stream = new MemoryStream())
                  {
                      var combinedName = Path.Combine(&quot;images/&quot;, blobItem.Name);
                      var blobClient = containerClient.GetBlobClient(combinedName);
  
                      await blobClient.DownloadToAsync(stream);
                      result.Add(
                      new AzureBlobResponse
                      {
                          Data = stream.ToArray(),
                          Filename = blobItem.Name
                      });
                  }
              }
          }
  </code></pre>
  <p>merely throws a &quot;System.FormatException&quot; regarding the input string. I then tried modifying my code to be as so:</p>
  <pre><code>private async Task NavigateBlobHierarchy(List&lt;AzureBlobResponse&gt; result, string? prefix)
      {
          var resultSegment = containerClient.GetBlobsByHierarchyAsync(prefix: prefix, delimiter: &quot;/&quot;)
              .AsPages();
  
          await foreach(var blobPage in resultSegment)
          {
              foreach(var blobItem in blobPage.Values)
              {
                  if(blobItem.IsPrefix)
                  {
                      await NavigateBlobHierarchy(result, blobItem.Prefix.Replace('/', ' ').Trim());
                  } else
                  {
                      using(var stream = new MemoryStream())
                      {
                          var combinedName = Path.Combine(&quot;images/&quot;, blobItem.Blob.Name);
                          var blobClient = containerClient.GetBlobClient(combinedName);
  
                          await blobClient.DownloadToAsync(stream);
                          result.Add(
                          new AzureBlobResponse
                          {
                              Data = stream.ToArray(),
                              Filename = blobItem.Blob.Name
                          });
                      }
                  }
              }
          }
      }
  </code></pre>
  <p>Where I call it like so:</p>
  <pre><code>        try
          {
              var listOfBlobs = new List&lt;AzureBlobResponse&gt;();
              await NavigateBlobHierarchy(listOfBlobs, &quot;images&quot;);
  
              return listOfBlobs;
          } catch (Exception e)
          {
              throw;
          }
  </code></pre>
  <p>This just ends up in an endless loop because it just getting hung up on the images prefix, and everything it always hits is images. What on earth am I doing wrong, this shouldn't be a complex issue to solve. I've done it before using an older API of Azure blob in a project for my old place, never had this oddity.</p>