求助:az storage account list返回空列表(此前可正常运行)
问题:
az storage account list返回空列表,此前可正常运行 我已通过az login完成登录,但执行az storage account list时返回空列表,之前该命令可正常返回结果。我同时使用多个Synapse及Azure账号,使用场景涵盖本地PyCharm、Azure门户、Synapse和开发网站。
环境信息
Azure CLI版本
az --version azure-cli 2.53.0 core 2.53.0 telemetry 1.1.0 Dependencies: msal 1.24.0b2 azure-mgmt-resource 23.1.0b2 Python location '/usr/local/Cellar/azure-cli/2.53.0/libexec/bin/python' Extensions directory '/Users/stephenboesch/.azure/cliextensions' Python (Darwin) 3.10.13 (main, Aug 24 2023, 22:48:59) [Clang 14.0.3 (clang-1403.0.22.14.1)] Legal docs and information: aka.ms/AzureCliLegal Your CLI is up-to-date.
az account show输出结果
$az account show { "environmentName": "AzureCloud", "homeTenantId": "*****b47", "id": "****499", "isDefault": true, "managedByTenants": [], "name": "Azure Portal Telemetry Reporting", "state": "Enabled", "tenantId": "*******b47", "user": { "name": "my-name@my-company.com", "type": "user" } }
可能的原因及解决步骤
1. 默认订阅切换到无存储账户的资源组
从az account show输出可见,当前默认订阅是Azure Portal Telemetry Reporting,该订阅内大概率没有存储账户。需切换回原有存储账户所在的订阅:
- 列出所有可用订阅:
az account list --output table - 找到目标订阅的ID或名称,切换默认订阅:
az account set --subscription <订阅ID/名称> - 重新执行
az storage account list验证结果。
2. 多账号登录导致上下文冲突
同时登录多个Azure账号时,CLI可能使用了错误的账号上下文:
- 查看所有已登录账号:
az account list --all --output table - 若目标账号不在列表内,重新登录指定账号:
或指定租户登录:az login --username <你的邮箱>az login --tenant <租户ID>
3. 账号权限变更
你的账号在目标订阅的权限可能被移除或调整,导致无法查看存储账户:
- 登录Azure门户,切换到目标订阅,检查当前账号的角色(如存储账户读者、参与者)是否存在。
- 若权限缺失,联系订阅管理员重新分配对应权限。
4. CLI上下文缓存异常
本地CLI的上下文缓存可能出现错误,尝试重置上下文:
az account clear
之后重新登录并设置默认订阅。
内容的提问来源于stack exchange,提问作者WestCoastProjects
相关产品推荐
相关产品推荐

