【问题标题】:azure Cli - Making multiple subscription as defaultazure Cli - 将多个订阅设为默认
【发布时间】:2021-02-19 07:31:26
【问题描述】:

我正在努力查找 Azure 订阅中所有存储帐户的列表。不幸的是,我们有大约 40 个订阅,有没有办法获得所有存储帐户。目前我只能在一个订阅中看到该列表,并且需要将订阅更改为另一个以查找存储帐户。

以下命令为我提供了默认订阅的存储帐户:
az storage account list --output table

【问题讨论】:

  • 你有机会检查我的答案吗?

标签: azure


【解决方案1】:

请安装graph扩展:
az extension add --name resource-graph

然后尝试以下方法:

az graph query -q                                         \
"Resources                                                \
| join kind=leftouter                                     \
    (                                                     \
        ResourceContainers                                \
        | where type=='microsoft.resources/subscriptions' \
        | project SubName=name, subscriptionId            \
    ) on subscriptionId                                   \
| where type == 'microsoft.storage/storageaccounts'       \
| project type, name, SubName"

Here我找到资源类型了。
我更改了大小写以使其正常工作。
This 文档为我提供了使查询正常工作的提示。

【讨论】:

    猜你喜欢
    • 2016-11-23
    • 2016-08-16
    • 2020-01-24
    • 2017-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多