使用az cli登录时遇Decryption failed错误,如何解决?
Azure CLI登录时Decryption failed: [WinError 87]错误修复方案
问题详情
执行az login时出现以下错误:
PS C:\Users\macie\Documents\workspace> az login Please select the account you want to log in with. Decryption failed: [WinError 87] App developer may consider this guidance: https://github.com/AzureAD/microsoft-authentication-extensions-for-python/wiki/PersistenceDecryptionError
当前Azure CLI版本信息:
PS C:\Users\macie\Documents\workspace> az --version azure-cli 2.61.0 core 2.61.0 telemetry 1.1.0 Extensions: account 0.2.5 ssh 2.0.3 storage-preview 1.0.0b1 Dependencies: msal 1.28.0 azure-mgmt-resource 23.1.1 Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe' Extensions directory 'C:\Users\macie\.azure\cliextensions' Python (Windows) 3.11.8 (tags/v3.11.8:db85d51, Feb 6 2024, 21:52:07) [MSC v.1937 32 bit (Intel)] Legal docs and information: aka.ms/AzureCliLegal Your CLI is up-to-date.
修复步骤
清除Azure CLI本地缓存:
删除用户目录下的.azure缓存文件夹,路径为C:\Users\macie\.azure。也可通过PowerShell命令执行:Remove-Item -Path $env:USERPROFILE\.azure -Recurse -Force执行后重新尝试
az login。使用设备码方式跳过缓存登录:
直接执行以下命令绕开本地缓存凭据,通过设备码完成登录:az login --use-device-code按照提示打开指定网址,输入显示的代码完成账户验证。
清理Windows凭据管理器中的Azure凭据:
- 打开控制面板,找到「凭据管理器」
- 切换到「Windows凭据」标签
- 删除所有名称包含「Azure」「Microsoft」相关的凭据条目
- 重新执行
az login
修复或重装Azure CLI:
如果以上方法均无效,卸载当前Azure CLI,从官方渠道下载最新版本重新安装,确保安装过程中无权限异常。
内容的提问来源于stack exchange,提问作者michasaucer
相关产品推荐
相关产品推荐

