azure - 如何使用 Azure CLI 获取存储帐户的 blob 列表?
问题描述
我正在使用 Microsoft Azure CLI,但找不到列出存储帐户的 blob 对象的方法。
我在 Azure Web 门户中显示了该列表,但我找不到任何可以使用该az storage
命令执行此操作的方法。
我已经尝试过az storage blob list
,但它需要一个我不知道如何找到它的容器名称(使用 az cli)。
有人有想法吗?
解决方案
更新:在 cli 中获取帐户密钥:
请尝试下面的代码,它可以列出存储帐户的所有容器中的所有 blob。
请注意,“=”周围没有空格。
# list storage account names
az storage account list --query "[].{name:name}" --output tsv)"
# update with your storage account name
storage_account_name="your_storage_account_name"
key="$(az storage account keys list -n ${storage_account_name} --query "[0].{value:value}" --output tsv)"
containers="$(az storage container list --account-name ${storage_account_name} --account-key $key --query "[].{name:name}" --output tsv)"
for c in $containers
do
echo "==== Blobs in Container $c ===="
az storage blob list --container-name $c \
--account-name ${storage_account_name} \
--account-key $key \
--query "[].{name:name}" --output tsv
done
测试结果如下:
推荐阅读
- python-3.x - 在 rhel 服务器上安装 python3 附加到 python 2.7
- java - 在 Kotlin 中:从两个映射中求和一个公共键的两个值的优雅方法是什么?
- python-3.x - 我需要用特殊参数制作类
- javascript - a .__ proto __ 和 b() 的比率
- docker - 服务“nginx-proxy”使用未定义的网络“nginx-proxy”
- ios - iOS Swift:Firebase 存储上传错误 - 只有初始文件上传有效
- flutter - 使用 Flutter TDD 基于 json 文件返回有效的名片模型
- css - WordPress中按字母分组的分类术语链接
- javascript - Mongoose - findByIdAndUpdate runValidators 基于其他属性
- sql - 连接表 - 如何找出要添加的 ID?