Repository: Azure/azure-cli-extensions

Issue:
az interactive will not work with azure-cli 2.0.62.
(env) D:\GitRepos\github>az interactive
Installing the Interactive extension..
The installed extension 'interactive' is in preview.
The command failed with an unexpected error. Here is the traceback:

cannot import name 'DEFAULTS_SECTION' from 'azure.cli.core._config' (d:\gitrepos\github\azure-cli\src\azure-cli-core\azure\cli\core\_config.py)
Traceback (most recent call last):
  File "D:\GitRepos\github\env\lib\site-packages\knack\cli.py", line 206, in invoke
    cmd_result = self.invocation.execute(args)
  File "d:\gitrepos\github\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 397, in execute
    raise ex
  File "d:\gitrepos\github\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 455, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "d:\gitrepos\github\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 448, in _run_job
    six.reraise(*sys.exc_info())
  File "D:\GitRepos\github\env\lib\site-packages\six.py", line 693, in reraise
    raise value
  File "d:\gitrepos\github\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 425, in _run_job
    result = cmd_copy(params)
  File "d:\gitrepos\github\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 145, in __call__
    return self.handler(*args, **kwargs)
  File "d:\gitrepos\github\azure-cli\src\azure-cli-core\azure\cli\core\__init__.py", line 454, in default_command_handler
    return op(**command_args)
  File "d:\gitrepos\github\azure-cli\src\command_modules\azure-cli-interactive\azure\cli\command_modules\interactive\custom.py", line 31, in start_shell
    azext_interactive.start_shell(cmd, style=style)
  File "C:\Users\trpresco\.azure\cliextensions\interactive\azext_interactive\__init__.py", line 10, in start_shell
    from .azclishell.app import AzInteractiveShell
  File "C:\Users\trpresco\.azure\cliextensions\interactive\azext_interactive\azclishell\app.py", line 35, in <module>
    from azure.cli.core._config import DEFAULTS_SECTION
ImportError: cannot import name 'DEFAULTS_SECTION' from 'azure.cli.core._config' (d:\gitrepos\github\azure-cli\src\azure-cli-core\azure\cli\core\_config.py)

To open an issue, please run: 'az feedback'


Discussion:

Resolving patch:
diff --git a/src/image-copy/azext_imagecopy/create_target.py b/src/image-copy/azext_imagecopy/create_target.py
--- a/src/image-copy/azext_imagecopy/create_target.py
+++ b/src/image-copy/azext_imagecopy/create_target.py
@@ -5,10 +5,12 @@
 
 import datetime
 import time
-from azext_imagecopy.cli_utils import run_cli_command, prepare_cli_command
-from knack.util import CLIError
 
+from knack.util import CLIError
 from knack.log import get_logger
+
+from azext_imagecopy.cli_utils import run_cli_command, prepare_cli_command
+
 logger = get_logger(__name__)
 
 STORAGE_ACCOUNT_NAME_LENGTH = 24
diff --git a/src/image-copy/azext_imagecopy/custom.py b/src/image-copy/azext_imagecopy/custom.py
--- a/src/image-copy/azext_imagecopy/custom.py
+++ b/src/image-copy/azext_imagecopy/custom.py
@@ -5,19 +5,20 @@
 
 from multiprocessing import Pool
 
+from knack.util import CLIError
+from knack.log import get_logger
+
 from azext_imagecopy.cli_utils import run_cli_command, prepare_cli_command
 from azext_imagecopy.create_target import create_target_image
 
-from knack.util import CLIError
-from knack.log import get_logger
 logger = get_logger(__name__)
 
 
 # pylint: disable=too-many-statements
 # pylint: disable=too-many-locals
 def imagecopy(source_resource_group_name, source_object_name, target_location,
-              target_resource_group_name, temporary_resource_group_name, source_type='image',
-              cleanup='false', parallel_degree=-1, tags=None, target_name=None,
+              target_resource_group_name, temporary_resource_group_name='image-copy-rg',
+              source_type='image', cleanup='false', parallel_degree=-1, tags=None, target_name=None,
               target_subscription=None, export_as_snapshot='false', timeout=3600):
 
     # get the os disk id from source vm/image
@@ -82,10 +83,10 @@ def imagecopy(source_resource_group_name, source_object_name, target_location,
 
     # Get SAS URL for the snapshotName
     logger.warn(
-        "Getting sas url for the source snapshot with timeout seconds: %d", timeout)
+        "Getting sas url for the source snapshot with timeout: %d seconds", timeout)
     if timeout < 3600:
-        logger.warn("Timeout should be greater than 3600")
-        raise CLIError('Inavlid Timeout')
+        logger.error("Timeout should be greater than 3600 seconds")
+        raise CLIError('Invalid Timeout')
 
     cli_cmd = prepare_cli_command(['snapshot', 'grant-access',
                                    '--name', source_os_disk_snapshot_name,
diff --git a/src/image-copy/setup.py b/src/image-copy/setup.py
--- a/src/image-copy/setup.py
+++ b/src/image-copy/setup.py
@@ -8,7 +8,7 @@
 from codecs import open
 from setuptools import setup, find_packages
 
-VERSION = "0.0.9"
+VERSION = "0.2.1"
 
 CLASSIFIERS = [
     'Development Status :: 4 - Beta',


Test patch: