Azure-cli: IOError if no .azure of azureProfile.json

Created on 29 Nov 2017  路  3Comments  路  Source: Azure/azure-cli

$ az
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/azure/cli/__main__.py", line 35, in <module>
    help_cls=AzCliHelp)
  File "/usr/local/lib/python2.7/dist-packages/azure/cli/core/__init__.py", line 47, in __init__
    ACCOUNT.load(os.path.join(azure_folder, 'azureProfile.json'))
  File "/usr/local/lib/python2.7/dist-packages/azure/cli/core/_session.py", line 42, in load
    self.save()
  File "/usr/local/lib/python2.7/dist-packages/azure/cli/core/_session.py", line 46, in save
    with codecs_open(self.filename, 'w', encoding=self._encoding) as f:
  File "/usr/lib/python2.7/codecs.py", line 896, in open
    file = __builtin__.open(filename, mode, buffering)
IOError: [Errno 2] No such file or directory: '/root/.azure/azureProfile.json'
$

cc: @troydai

Knack P1 bug

All 3 comments

Does this not happen on the dev branch?

from knack.util import ensure_dir
ensure_dir(azure_folder)

Can add that to the constructor of AzCli.

This could potentially be done in the knack CLIConfig constructor as well. - https://github.com/Microsoft/knack/blob/master/knack/config.py#L27

It doesn't happen on the dev branch.
I noticed because it fails on prompt.ws as no .azure dir exists. On dev branch, it works fine.

Was this page helpful?
0 / 5 - 0 ratings