List directories in a container

2019-07-01 12:22发布

问题:

How can I get a list of directories in my container?

I can use Get-AzureStorageBlob to get all the blobs and filter by distinct prefix /name/, but it might be slow with millions of blobs.

Is there a proper way of achieving this in PowerShell?

回答1:

There's no concept of directories, only containers and blobs. A blob name may have delimiters with look like directories, and may be filtered.

If you choose to store millions of blobs in a container, then you'll be searching through millions of blob names, even with delimiter filtering, whether using PowerShell, SDK, or direct REST calls.

As far as "proper" way: There is no proper way: Only you can decide how you organize your containers and blobs, and where (or if) you choose to store metadata for more efficient searching (such as a database).