使用 Azure CLI 登录到 Azure 容器服务失败,错误为 'bool' object has no attribute 'rstrip'

Login to the Azure-container-service fails with error 'bool' object has no attribute 'rstrip' using Azure CLI

问题: az acr 登录 --name test1acr

Azure CLI 版本:azure-cli (2.0.24) docker版本:17.12.0-ce

Error : 'bool' object has no attribute 'rstrip' Traceback (most recent call last): File "/home/vagrant/lib/azure-cli/lib/python2.7/site-packages/knack/cli.py", line 193, in invoke cmd_result = self.invocation.execute(args) File "/home/vagrant/lib/azure-cli/lib/python2.7/site-packages/azure/cli/core/commands/init.py", line 319, in execute six.reraise(*sys.exc_info()) File "/home/vagrant/lib/azure-cli/lib/python2.7/site-packages/azure/cli/core/commands/init.py", line 292, in execute result = cmd(params) File "/home/vagrant/lib/azure-cli/lib/python2.7/site-packages/azure/cli/core/commands/init.py", line 169, in call return super(AzCliCommand, self).call(*args, **kwargs) File "/home/vagrant/lib/azure-cli/lib/python2.7/site-packages/knack/commands.py", line 109, in call return self.handler(*args, **kwargs) File "/home/vagrant/lib/azure-cli/lib/python2.7/site-packages/azure/cli/core/init.py", line 328, in default_command_handler result = op(**command_args) File "/home/vagrant/lib/azure-cli/lib/python2.7/site-packages/azure/cli/command_modules/acr/custom.py", line 195, in acr_login password=password) File "/home/vagrant/lib/azure-cli/lib/python2.7/site-packages/azure/cli/command_modules/acr/_docker_utils.py", line 194, in get_login_credentials only_refresh_token=True) File "/home/vagrant/lib/azure-cli/lib/python2.7/site-packages/azure/cli/command_modules/acr/_docker_utils.py", line 150, in _get_credentials password = _get_aad_token(login_server, only_refresh_token, repository, permission) File "/home/vagrant/lib/azure-cli/lib/python2.7/site-packages/azure/cli/command_modules/acr/_docker_utils.py", line 35, in _get_aad_token login_server = login_server.rstrip('/') AttributeError: 'bool' object has no attribute 'rstrip'

docker 实用程序中似乎缺少 Azure cli 上下文。 通过修改 _docker_utils 文件

,以下更改对我有用

文件:/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/acr/_docker_utils.py
行号:150

-            password = _get_aad_token(login_server, only_refresh_token, repository, permission)
+            password = _get_aad_token( cli_ctx , login_server, only_refresh_token, repository, permission)

现在最好回到 2.0.23,因为 2.0.24 引入了一个错误。