Azure CLI:存储Blob Delete-batch删除除两个目录之外的所有Blob [英] Azure CLI: storage blob delete-batch to delete all blobs excluding two directories

查看:126
本文介绍了Azure CLI:存储Blob Delete-batch删除除两个目录之外的所有Blob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PowerShell脚本,当前可以删除$ web容器中的所有blob.

az storage blob delete-batch --account-name myaccountname --source $web

这很好用,但是现在我要排除两个目录,以免它们被删除.我查看了文档,但我仍然不确定排除语法的外观.

我确定我必须使用--pattern参数.

用于在源文件中遍历文件或Blob的模式.支持的模式是"*",?","[seq]"和"[!seq]".

我希望有人可以让我知道--pattern参数的值应该是什么样,以便可以删除$ web容器中除/aaa/bbb目录中的blob之外的所有内容./p>

az storage blob delete-batch --account-name myaccountname --source $web --pattern ???

解决方案

根据我的测试,如果要参数--pattern以排除要删除的目录,则可以使用表达式'[[!]]'

az storage blob delete-batch --source <container_name> --account-name <storage_account_name> --pattern '[!<folder name>]*'

例如:

  1. 运行命令之前,容器的结构如下.

  1. 运行命令

    az storage blob delete-batch --source test --account-name blobstorage0516 --pattern '[!user&&!people]*'

  1. 运行命令后,容器的结构如下.

I have a PowerShell script that currently deletes all blobs in my $web container.

az storage blob delete-batch --account-name myaccountname --source $web

This works great, but now I want to exclude two directories from being deleted. I've looked over the documentation and I'm still not sure how the exclusion syntax is supposed to look.

I'm certain that I have to use the --pattern parameter.

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

I'm hoping someone can let me know what the value of the --pattern param should look like so that I can delete everything in the $web container except the blobs in the /aaa and /bbb directories.

az storage blob delete-batch --account-name myaccountname --source $web --pattern ???

解决方案

According to my test, if you want to parameter --pattern to exclude a directory from being deleted, you can use the expression '[[!]]'

az storage blob delete-batch --source <container_name> --account-name <storage_account_name> --pattern '[!<folder name>]*'

For example:

  1. The structure of my container is as below before I run the command.

  1. Run the command

    az storage blob delete-batch --source test --account-name blobstorage0516 --pattern '[!user&&!people]*'

  1. The structure of my container is as below after I run the command.

这篇关于Azure CLI:存储Blob Delete-batch删除除两个目录之外的所有Blob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆