Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what does 'az storage blob delete-batch' do? #5722

Closed
ormico opened this issue Mar 3, 2018 · 8 comments
Closed

what does 'az storage blob delete-batch' do? #5722

ormico opened this issue Mar 3, 2018 · 8 comments
Labels
Documentation question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Storage az storage

Comments

@ormico
Copy link

ormico commented Mar 3, 2018

I'm trying to delete a large number of blobs from a storage container. I'm currently using delete but I saw delete-batch and was interested if it would help. However, I found the documentation to be a little sparse as to what it actually does.

The doc page
https://docs.microsoft.com/en-us/cli/azure/storage/blob?view=azure-cli-latest#az_storage_blob_delete_batch
says

Delete blobs from a blob container recursively.

as its only description of it's functionality.

Can someone explain what this is supposed to do or how it works? The above description wasn't clear to me.

Thanks.

@tjprescott tjprescott added Storage az storage Documentation question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Mar 5, 2018
@williexu
Copy link
Contributor

williexu commented Mar 7, 2018

storage blob delete-batch was made for situations like yours, where a large number of blobs need to be deleted.
Essentially, bare-bones, you can specify a container using the --source/-s and all blobs will be deleted from said container.
You can narrow down the scope by using the --pattern parameter; e.g. using --pattern directory* will delete all blobs who's name starts with "directory"

@ormico
Copy link
Author

ormico commented Mar 7, 2018

Thanks. I ended up doing it through powershell but it took a long time to run.

What kind of patterns does --pattern support. The doc says

--pattern
The pattern used for globbing files or blobs in the source. The supported patterns are '*', '?', '[seq]', and '[!seq]'.

Would "myapp_log_*.trn" work?

I don't recognize [seq]. What type of pattern is that?

@williexu
Copy link
Contributor

williexu commented Mar 7, 2018

myapp_log_*.trn would match myapp_log_<any character(s)>.trn.
If that your goal, then yes.
[seq] allows you to specify a number of characters to match for.
We are using fnmatch under the hood.

@arbaiti
Copy link

arbaiti commented Mar 9, 2018

Hello,
I need to do cleanup of dump files on a blob container, and i don't know how to use this command.
I should delete dump older than 14 days.
Regards,

@williexu
Copy link
Contributor

williexu commented Mar 9, 2018

@arbaiti use the --if-unmodified-since parameter.
#5286 should be fixed with our next release.

In the meantime, you can query for the properties.lastModified datetime value and compare it with the datetime you want.

This should also answer your question: #5575 (comment)
Next time, please limit your comments to one issue (or file a new issue) if they are all related.

@arbaiti
Copy link

arbaiti commented Mar 13, 2018

Do you have any example with --if-unmodified-since parameter ?

@williexu
Copy link
Contributor

Bash:

az storage blob delete-batch --source backups --if-unmodified-since `date -ud "14 day ago" '+%Y-%m-%dT%H:%MZ'`

@arbaiti
Copy link

arbaiti commented Mar 16, 2018

Thanks for your reply i'll test it

@haroldrandom haroldrandom added Documentation question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Storage az storage labels Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Storage az storage
Projects
None yet
Development

No branches or pull requests

5 participants