title: How to list all blobs inside of a specific subdirectory in Azure Cloud Storage using Python?
body: <p>I worked through the example code from the Azure docs <a href="https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-python" rel="noreferrer">https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-python</a></p>
  
  <pre><code>from azure.storage.blob import BlockBlobService
  account_name = "x"
  account_key = "x"
  top_level_container_name = "top_container"
  
  blob_service = BlockBlobService(account_name, account_key)
  
  print("\nList blobs in the container")
  generator = blob_service.list_blobs(top_level_container_name)
  for blob in generator:
      print("\t Blob name: " + blob.name)
  </code></pre>
  
  <p>Now I would like to know how to get more fine grained in my container walking. My container top_level_container_name has several subdirectories </p>
  
  <ul>
  <li>top_level_container_name/dir1</li>
  <li>top_level_container_name/dir2</li>
  <li>etc in that pattern</li>
  </ul>
  
  <p>I would like to be able to list all of the blobs that are inside just one of those directories. For instance </p>
  
  <ul>
  <li>dir1/a.jpg</li>
  <li>dir1/b.jpg</li>
  <li>etc</li>
  </ul>
  
  <p>How do I get a generator of just the contents of dir1 without having to walk all of the other dirs? (I would also take a list or dictionary)</p>
  
  <p>I tried adding /dir1 to the name of the top_level_container_name so it would be <code>top_level_container_name = "top_container/dir1"</code> but that didn't work. I get back an error code   <code>azure.common.AzureHttpError: The requested URI does not represent any resource on the server. ErrorCode: InvalidUri</code></p>
  
  <p>The docs do not seem to even have any info on BlockBlobService.list_blobs() <a href="https://docs.microsoft.com/en-us/python/api/azure.storage.blob.blockblobservice.blockblobservice?view=azure-python" rel="noreferrer">https://docs.microsoft.com/en-us/python/api/azure.storage.blob.blockblobservice.blockblobservice?view=azure-python</a></p>
  
  <p>Update:
  list_blobs() comes from <a href="https://github.com/Azure/azure-storage-python/blob/ff51954d1b9d11cd7ecd19143c1c0652ef1239cb/azure-storage-blob/azure/storage/blob/baseblobservice.py#L1202" rel="noreferrer">https://github.com/Azure/azure-storage-python/blob/ff51954d1b9d11cd7ecd19143c1c0652ef1239cb/azure-storage-blob/azure/storage/blob/baseblobservice.py#L1202</a> </p>