Azure CLI报错:模块无CorsRuleAllowedMethodsItem属性,存储账户未找到
Azure CLI存储文件下载AttributeError问题排查
问题描述
尝试执行以下Azure CLI命令递归下载存储文件:
az storage fs directory download --recursive -s path/to/my/file/myfile.parquet --account-name my-account-name --f my-storage-acct -d local-directory
已通过az login成功重新登录,该操作此前针对目标存储账户正常运行数周,但现在触发AttributeError错误,同时输出日志包含:
Skip querying account key due to failure: Storage account 'saddexdatamsftdevppe' not found. INFO: cli.azure.cli.command_modules.storage._validators: Cannot generate sas token. self.account_key should not be None
已在Azure门户中确认该存储账户及目标文件均存在。
排查与解决步骤
- 核对存储账户名称:错误提示中提到的存储账户名为
saddexdatamsftdevppe,但命令中--account-name参数值为my-account-name,需确认两者是否一致,命令中必须填写存储账户的准确全名。 - 确认当前订阅上下文:执行
az account show查看当前登录的Azure订阅,若目标存储账户不在该订阅内,使用az account set --subscription <订阅ID或名称>切换到正确订阅。 - 手动指定身份验证凭据:若CLI自动获取账户密钥失败,可手动传入账户密钥或SAS令牌:
- 使用账户密钥:
az storage fs directory download --recursive -s path/to/my/file/myfile.parquet --account-name <正确存储账户名> --account-key <账户密钥> --f my-storage-acct -d local-directory - 使用SAS令牌:
az storage fs directory download --recursive -s path/to/my/file/myfile.parquet --account-name <正确存储账户名> --sas-token <有效SAS令牌> --f my-storage-acct -d local-directory
- 使用账户密钥:
- 更新Azure CLI版本:旧版本CLI可能存在已知bug,执行
az upgrade将CLI更新至最新稳定版后重试操作。 - 验证用户RBAC权限:确认当前登录的Azure AD用户对目标存储账户拥有Storage Blob Data Contributor或更高权限,若权限不足,在Azure门户的存储账户「访问控制(IAM)」中添加对应角色。
内容的提问来源于stack exchange,提问作者WestCoastProjects
相关产品推荐
相关产品推荐

