Azure Cli 在输入“az login”时给我权限错误

问题描述 投票:0回答:4

我刚刚安装了 Azure Cli,当我尝试使用 az login 登录我的 Azure 帐户时,出现错误 -

The error - Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.28.0/libexec/lib/python3.9/site-packages/azure/cli/core/_session.py", line 48, in load
    with codecs_open(self.filename, 'r', encoding=self._encoding) as f:
  File "/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/codecs.py", line 905, in open
    file = builtins.open(filename, mode, buffering)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/mawada14/.azure/azureProfile.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/Cellar/azure-cli/2.28.0/libexec/lib/python3.9/site-packages/azure/cli/__main__.py", line 38, in <module>
    az_cli = get_default_cli()
  File "/usr/local/Cellar/azure-cli/2.28.0/libexec/lib/python3.9/site-packages/azure/cli/core/__init__.py", line 912, in get_default_cli
    return AzCli(cli_name='az',
  File "/usr/local/Cellar/azure-cli/2.28.0/libexec/lib/python3.9/site-packages/azure/cli/core/__init__.py", line 80, in __init__
    ACCOUNT.load(os.path.join(azure_folder, 'azureProfile.json'))
  File "/usr/local/Cellar/azure-cli/2.28.0/libexec/lib/python3.9/site-packages/azure/cli/core/_session.py", line 61, in load
    self.save()
  File "/usr/local/Cellar/azure-cli/2.28.0/libexec/lib/python3.9/site-packages/azure/cli/core/_session.py", line 65, in save
    with codecs_open(self.filename, 'w', encoding=self._encoding) as f:
  File "/usr/local/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/codecs.py", line 905, in open
    file = builtins.open(filename, mode, buffering)
PermissionError: [Errno 13] Permission denied: '/Users/mawada14/.azure/azureProfile.json'
azure azure-cli
4个回答
1
投票

我刚刚遇到了同样的问题,似乎在 Linux 上安装期间,

.azure
目录没有被分配正确的权限让客户端以某种方式工作。

我开始使用 chmod 手动设置权限,如下所示:

sudo chmod 777 $HOME/.azure/az.sess
sudo chmod 444 $HOME/.azure/config
sudo chmod 777 $HOME/.azure/versionCheck.json
sudo chmod 777 $HOME/.azure/commandIndex.json
# At this point I had enough and just added all permissions to the whole folder
sudo chmod 777 $HOME/.azure/*

通过这样做,我成功登录了


0
投票

我做了以下更改并且有效

sudo chown -R $USER:$USER $HOME/.azure/

本质上是将所有文件的所有权递归地转移给当前用户。


-1
投票

我按照此 Microsoft 文档 进行操作,并能够使用 CLI cmd 登录我的 azure 门户

az login

enter image description here

欲了解更多信息,请参阅以下链接:

运行“az login | 后出现权限被拒绝”错误GitHub.

使用 Azure CLI 登录 | MS 文档


-2
投票
© www.soinside.com 2019 - 2024. All rights reserved.