简体   繁体   中英

Listing required Azure container files/file types using PowerShell

I have two azure containers. One filled with lot of files and other is new container. With Azure storage explorer, the container with lot files does not work as it hangs due to large data in it. I would like to see the files of my interest using Powershell and move them to new container.

Get-AzureStorageBlob -Container $container -Context $destContext lists all the blobs which is not practically good option as it is difficult to search all blobs as data is huge.

I want to search say for example only .csv files or .txt files or search with part of name using "Powershell". How can it be done?

Note:

I tried to use

Get-ChildItem Get-AzureStorageBlob -Container $container -Context $destContext | Where-Object {$_.name -like "*.csv"}

But this did not work.

Could you please help me to achieve this using Powershell?

Here is one way:

get-azurestorageblob -Container test -blob *.csv

That will get you a list of all the csv files in the container.

The REST API itself doesn't support filtering server side beyond the concept of a prefix. You can pass a -Prefix parameter and on the server it will scope the results down to only BLOBs that start with that prefix. This is most often done to get all the BLOBs that reside in the same "folder" on a container (note folders aren't really supported in BLOB storage, the "path" is just part of the BLOB name).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM