Azure / azure-cli

Azure Command-Line Interface
MIT License
3.97k stars 2.95k forks source link

Cannot get deployment logs from Azure using python module azure.cli #18911

Open Kreetik-T opened 3 years ago

Kreetik-T commented 3 years ago

This is autogenerated. Please review and update as needed.

I am trying to retrieve deployment center logs for an app service in Azure using python and the azure.cli library. Other commands like az group list work just fine but this one seems to be returning an error. I've tried using pip to uninstall and reinstall the module 'nacl' that appears to be missing, but pip could neither find it on my system for uninstalling, nor could it find a version online.

Command Name az webapp log deployment list

Errors:

The command failed with an unexpected error. Here is the traceback:
No module named 'nacl._sodium'
Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\knack\cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "C:\Users\kreet\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\__init__.py", line 556, in execute
    self.commands_loader.load_arguments(command)
  File "C:\Users\kreet\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\__init__.py", line 517, in load_arguments
    self.command_table[command].load_arguments()  # this loads the arguments via reflection
  File "C:\Users\kreet\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\__init__.py", line 313, in load_arguments
    super(AzCliCommand, self).load_arguments()
  File "C:\Python39\lib\site-packages\knack\commands.py", line 104, in load_arguments
    cmd_args = self.arguments_loader()
  File "C:\Users\kreet\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\command_operation.py", line 125, in arguments_loader
    op = self.get_op_handler(self.op_path)
  File "C:\Users\kreet\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\command_operation.py", line 59, in get_op_handler
    handler = import_module(mod_to_import)
  File "C:\Python39\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:\Users\kreet\AppData\Roaming\Python\Python39\site-packages\azure\cli\command_modules\appservice\custom.py", line 22, in <module>
    from nacl import encoding, public
  File "C:\Users\kreet\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\nacl\public.py", line 17, in <module>
    import nacl.bindings
  File "C:\Users\kreet\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\nacl\bindings\__init__.py", line 17, in <module>
    from nacl.bindings.crypto_aead import (
  File "C:\Users\kreet\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\nacl\bindings\crypto_aead.py", line 18, in <module>
    from nacl._sodium import ffi, lib
ModuleNotFoundError: No module named 'nacl._sodium'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

Expected Behavior

Environment Summary

Windows-10-10.0.19041-SP0
Python 3.8.9
Installer: MSI

azure-cli 2.26.0 *

Additional Context

ghost commented 3 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AzureAppServiceCLI, @antcp.

Issue Details
### **This is autogenerated. Please review and update as needed.** ## I am trying to retrieve deployment center logs for an app service in Azure using python and the azure.cli library. Other commands like `az group list` seem to be working just fine but this one seems to be returning an error. I've tried using pip to uninstall and reinstall the module 'nacl' that seems to be missing, but pip could neither find it on my system for uninstalling, nor could it find a version online. **Command Name** `az webapp log deployment list` **Errors:** ``` The command failed with an unexpected error. Here is the traceback: No module named 'nacl._sodium' Traceback (most recent call last): File "C:\Python39\lib\site-packages\knack\cli.py", line 231, in invoke cmd_result = self.invocation.execute(args) File "C:\Users\kreet\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\__init__.py", line 556, in execute self.commands_loader.load_arguments(command) File "C:\Users\kreet\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\__init__.py", line 517, in load_arguments self.command_table[command].load_arguments() # this loads the arguments via reflection File "C:\Users\kreet\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\__init__.py", line 313, in load_arguments super(AzCliCommand, self).load_arguments() File "C:\Python39\lib\site-packages\knack\commands.py", line 104, in load_arguments cmd_args = self.arguments_loader() File "C:\Users\kreet\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\command_operation.py", line 125, in arguments_loader op = self.get_op_handler(self.op_path) File "C:\Users\kreet\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\command_operation.py", line 59, in get_op_handler handler = import_module(mod_to_import) File "C:\Python39\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 850, in exec_module File "", line 228, in _call_with_frames_removed File "C:\Users\kreet\AppData\Roaming\Python\Python39\site-packages\azure\cli\command_modules\appservice\custom.py", line 22, in from nacl import encoding, public File "C:\Users\kreet\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\nacl\public.py", line 17, in import nacl.bindings File "C:\Users\kreet\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\nacl\bindings\__init__.py", line 17, in from nacl.bindings.crypto_aead import ( File "C:\Users\kreet\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\nacl\bindings\crypto_aead.py", line 18, in from nacl._sodium import ffi, lib ModuleNotFoundError: No module named 'nacl._sodium' ``` ## To Reproduce: Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information. - _Put any pre-requisite steps here..._ - `az webapp log deployment list --name {} --resource-group {}` ## Expected Behavior ## Environment Summary ``` Windows-10-10.0.19041-SP0 Python 3.8.9 Installer: MSI azure-cli 2.26.0 * ``` ## Additional Context
Author: Kreetik-T
Assignees: -
Labels: `Service Attention`, `Web Apps`
Milestone: -
yonzhan commented 3 years ago

route to service team

jiasli commented 3 years ago

Judging by the call stack

File "C:\Python39\lib\site-packages\knack\cli.py", line 231, in invoke
...
  File "C:\Users\kreet\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\__init__.py", line 556, in execute
...
  File "C:\Users\kreet\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\nacl\public.py", line 17, in <module>

you have multiple Pythons (at least 3.9 and 3.7) installed and sys.path pointes to various source folders:

You have also installed Azure CLI by yourself previously with pip which corrupts the dependency resolution.

Please follow the official doc to Install Azure CLI on Windows and make sure C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd can be found first on your PATH environment variable:

# PowerShell
> (Get-Command az).source
C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd

> echo $env:PATH
C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\WINDOWS\system32;...

(You may also consider removing unused Pythons.)