diff --git a/azure-cli2017.pyproj b/azure-cli2017.pyproj
index b97db287703..f1e09e0e224 100644
--- a/azure-cli2017.pyproj
+++ b/azure-cli2017.pyproj
@@ -498,22 +498,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -670,7 +654,6 @@
-
Code
@@ -1123,7 +1106,6 @@
-
diff --git a/scripts/dependency/requirements.Darwin.external.txt b/scripts/dependency/requirements.Darwin.external.txt
new file mode 100644
index 00000000000..4481aa18a50
--- /dev/null
+++ b/scripts/dependency/requirements.Darwin.external.txt
@@ -0,0 +1,107 @@
+adal==1.1.0
+antlr4-python3-runtime==4.7.1
+applicationinsights==0.11.6
+argcomplete==1.9.4
+asn1crypto==0.24.0
+azure-batch==5.0.0
+azure-common==1.1.15
+azure-datalake-store==0.0.31
+azure-graphrbac==0.40.0
+azure-keyvault==1.1.0
+azure-mgmt-advisor==1.0.1
+azure-mgmt-authorization==0.50.0
+azure-mgmt-batch==5.0.1
+azure-mgmt-batchai==2.0.0
+azure-mgmt-billing==0.2.0
+azure-mgmt-botservice==0.1.0
+azure-mgmt-cdn==3.0.0
+azure-mgmt-cognitiveservices==3.0.0
+azure-mgmt-compute==4.1.0
+azure-mgmt-consumption==2.0.0
+azure-mgmt-containerinstance==1.1.0
+azure-mgmt-containerregistry==2.2.0
+azure-mgmt-containerservice==4.2.2
+azure-mgmt-cosmosdb==0.4.0
+azure-mgmt-datalake-analytics==0.2.0
+azure-mgmt-datalake-nspkg==2.0.0
+azure-mgmt-datalake-store==0.5.0
+azure-mgmt-datamigration==0.1.0
+azure-mgmt-devtestlabs==2.2.0
+azure-mgmt-dns==2.1.0
+azure-mgmt-iotcentral==0.2.0
+azure-mgmt-iothub==0.6.0
+azure-mgmt-iothubprovisioningservices==0.2.0
+azure-mgmt-keyvault==1.1.0
+azure-mgmt-loganalytics==0.2.0
+azure-mgmt-managementgroups==0.1.0
+azure-mgmt-maps==0.1.0
+azure-mgmt-marketplaceordering==0.1.0
+azure-mgmt-media==1.0.0rc1
+azure-mgmt-monitor==0.5.2
+azure-mgmt-msi==0.2.0
+azure-mgmt-network==2.3.0
+azure-mgmt-nspkg==2.0.0
+azure-mgmt-policyinsights==0.1.0
+azure-mgmt-rdbms==1.3.0
+azure-mgmt-recoveryservices==0.1.0
+azure-mgmt-recoveryservicesbackup==0.1.1
+azure-mgmt-redis==5.0.0
+azure-mgmt-relay==0.1.0
+azure-mgmt-reservations==0.3.0
+azure-mgmt-resource==2.0.0
+azure-mgmt-search==2.0.0
+azure-mgmt-servicebus==0.5.1
+azure-mgmt-servicefabric==0.2.0
+azure-mgmt-signalr==0.1.1
+azure-mgmt-sql==0.9.1
+azure-mgmt-storage==2.0.0rc4
+azure-mgmt-trafficmanager==0.50.0
+azure-mgmt-web==0.40.0
+azure-multiapi-storage==0.2.2
+azure-nspkg==2.0.0
+azure-storage-blob==1.1.0
+azure-storage-common==1.1.0
+azure-storage-nspkg==3.0.0
+bcrypt==3.1.4
+certifi==2018.8.24
+cffi==1.11.5
+chardet==3.0.4
+colorama==0.3.9
+cryptography==2.3.1
+entrypoints==0.2.3
+humanfriendly==4.16.1
+idna==2.7
+isodate==0.6.0
+jmespath==0.9.3
+keyring==15.1.0
+knack==0.5.1
+mock==2.0.0
+msrest==0.5.5
+msrestazure==0.4.34
+oauthlib==2.1.0
+paramiko==2.4.1
+pbr==4.2.0
+portalocker==1.2.1
+prompt-toolkit==1.0.15
+pyasn1==0.4.4
+pycparser==2.18
+pydocumentdb==2.3.3
+Pygments==2.2.0
+PyJWT==1.6.4
+PyNaCl==1.2.1
+pyOpenSSL==18.0.0
+python-dateutil==2.7.3
+pytz==2018.5
+PyYAML==3.13
+requests==2.19.1
+requests-oauthlib==1.0.0
+scp==0.11.0
+six==1.11.0
+sshtunnel==0.1.4
+tabulate==0.8.2
+urllib3==1.23
+vsts-cd-manager==1.0.2
+wcwidth==0.1.7
+websocket-client==0.53.0
+Whoosh==2.7.4
+xmltodict==0.11.0
diff --git a/scripts/dependency/requirements.Linux.external.txt b/scripts/dependency/requirements.Linux.external.txt
new file mode 100644
index 00000000000..ec8483493bc
--- /dev/null
+++ b/scripts/dependency/requirements.Linux.external.txt
@@ -0,0 +1,109 @@
+adal==1.1.0
+antlr4-python3-runtime==4.7.1
+applicationinsights==0.11.6
+argcomplete==1.9.4
+asn1crypto==0.24.0
+azure-batch==5.0.0
+azure-common==1.1.15
+azure-datalake-store==0.0.31
+azure-graphrbac==0.40.0
+azure-keyvault==1.1.0
+azure-mgmt-advisor==1.0.1
+azure-mgmt-authorization==0.50.0
+azure-mgmt-batch==5.0.1
+azure-mgmt-batchai==2.0.0
+azure-mgmt-billing==0.2.0
+azure-mgmt-botservice==0.1.0
+azure-mgmt-cdn==3.0.0
+azure-mgmt-cognitiveservices==3.0.0
+azure-mgmt-compute==4.1.0
+azure-mgmt-consumption==2.0.0
+azure-mgmt-containerinstance==1.1.0
+azure-mgmt-containerregistry==2.2.0
+azure-mgmt-containerservice==4.2.2
+azure-mgmt-cosmosdb==0.4.0
+azure-mgmt-datalake-analytics==0.2.0
+azure-mgmt-datalake-nspkg==2.0.0
+azure-mgmt-datalake-store==0.5.0
+azure-mgmt-datamigration==0.1.0
+azure-mgmt-devtestlabs==2.2.0
+azure-mgmt-dns==2.1.0
+azure-mgmt-iotcentral==0.2.0
+azure-mgmt-iothub==0.6.0
+azure-mgmt-iothubprovisioningservices==0.2.0
+azure-mgmt-keyvault==1.1.0
+azure-mgmt-loganalytics==0.2.0
+azure-mgmt-managementgroups==0.1.0
+azure-mgmt-maps==0.1.0
+azure-mgmt-marketplaceordering==0.1.0
+azure-mgmt-media==1.0.0rc1
+azure-mgmt-monitor==0.5.2
+azure-mgmt-msi==0.2.0
+azure-mgmt-network==2.3.0
+azure-mgmt-nspkg==2.0.0
+azure-mgmt-policyinsights==0.1.0
+azure-mgmt-rdbms==1.3.0
+azure-mgmt-recoveryservices==0.1.0
+azure-mgmt-recoveryservicesbackup==0.1.1
+azure-mgmt-redis==5.0.0
+azure-mgmt-relay==0.1.0
+azure-mgmt-reservations==0.3.0
+azure-mgmt-resource==2.0.0
+azure-mgmt-search==2.0.0
+azure-mgmt-servicebus==0.5.1
+azure-mgmt-servicefabric==0.2.0
+azure-mgmt-signalr==0.1.1
+azure-mgmt-sql==0.9.1
+azure-mgmt-storage==2.0.0rc4
+azure-mgmt-trafficmanager==0.50.0
+azure-mgmt-web==0.40.0
+azure-multiapi-storage==0.2.2
+azure-nspkg==2.0.0
+azure-storage-blob==1.1.0
+azure-storage-common==1.1.0
+azure-storage-nspkg==3.0.0
+bcrypt==3.1.4
+certifi==2018.8.24
+cffi==1.11.5
+chardet==3.0.4
+colorama==0.3.9
+cryptography==2.3.1
+entrypoints==0.2.3
+humanfriendly==4.16.1
+idna==2.7
+isodate==0.6.0
+jeepney==0.3.1
+jmespath==0.9.3
+keyring==15.1.0
+knack==0.5.1
+mock==2.0.0
+msrest==0.5.5
+msrestazure==0.4.34
+oauthlib==2.1.0
+paramiko==2.4.1
+pbr==4.2.0
+portalocker==1.2.1
+prompt-toolkit==1.0.15
+pyasn1==0.4.4
+pycparser==2.18
+pydocumentdb==2.3.3
+Pygments==2.2.0
+PyJWT==1.6.4
+PyNaCl==1.2.1
+pyOpenSSL==18.0.0
+python-dateutil==2.7.3
+pytz==2018.5
+PyYAML==3.13
+requests==2.19.1
+requests-oauthlib==1.0.0
+scp==0.11.0
+SecretStorage==3.1.0
+six==1.11.0
+sshtunnel==0.1.4
+tabulate==0.8.2
+urllib3==1.23
+vsts-cd-manager==1.0.2
+wcwidth==0.1.7
+websocket-client==0.53.0
+Whoosh==2.7.4
+xmltodict==0.11.0
diff --git a/src/azure-cli-core/azure/cli/core/__init__.py b/src/azure-cli-core/azure/cli/core/__init__.py
index 2f39ed6e737..a1909677eb0 100644
--- a/src/azure-cli-core/azure/cli/core/__init__.py
+++ b/src/azure-cli-core/azure/cli/core/__init__.py
@@ -12,7 +12,6 @@
import six
-from knack.arguments import ArgumentsContext
from knack.cli import CLI
from knack.commands import CLICommandsLoader
from knack.completion import ARGCOMPLETE_ENV_NAME
@@ -242,13 +241,14 @@ def load_arguments(self, command):
command_loaders = self.cmd_to_loader_map.get(command, None)
if command_loaders:
- with ArgumentsContext(self, '') as c:
- c.argument('resource_group_name', resource_group_name_type)
- c.argument('location', get_location_type(self.cli_ctx))
- c.argument('deployment_name', deployment_name_type)
- c.argument('cmd', ignore_type)
-
for loader in command_loaders:
+ # register global args
+ with loader.argument_context('') as c:
+ c.argument('resource_group_name', resource_group_name_type)
+ c.argument('location', get_location_type(self.cli_ctx))
+ c.argument('deployment_name', deployment_name_type)
+ c.argument('cmd', ignore_type)
+
loader.command_name = command
self.command_table[command].load_arguments() # this loads the arguments via reflection
loader.load_arguments(command) # this adds entries to the argument registries
diff --git a/src/azure-cli-core/azure/cli/core/_help.py b/src/azure-cli-core/azure/cli/core/_help.py
index 5977508c66d..b701a4ca8f4 100644
--- a/src/azure-cli-core/azure/cli/core/_help.py
+++ b/src/azure-cli-core/azure/cli/core/_help.py
@@ -9,7 +9,6 @@
HelpFile as KnackHelpFile,
CommandHelpFile as KnackCommandHelpFile,
CLIHelp,
- HelpParameter,
ArgumentGroupRegistry as KnackArgumentGroupRegistry)
from knack.log import get_logger
@@ -101,21 +100,8 @@ def _should_include_example(self, ex):
# Needs to override base implementation
def _load_from_data(self, data):
- if not data:
- return
-
- if isinstance(data, str):
- self.long_summary = data
- return
-
- if 'type' in data:
- self.type = data['type']
-
- if 'short-summary' in data:
- self.short_summary = data['short-summary']
-
- self.long_summary = data.get('long-summary')
-
+ super(CliHelpFile, self)._load_from_data(data)
+ self.examples = [] # clear examples set by knack
if 'examples' in data:
self.examples = []
for d in data['examples']:
@@ -126,47 +112,8 @@ def _load_from_data(self, data):
class CliCommandHelpFile(KnackCommandHelpFile, CliHelpFile):
def __init__(self, help_ctx, delimiters, parser):
- super(CliCommandHelpFile, self).__init__(help_ctx, delimiters, parser)
- import argparse
- self.type = 'command'
self.command_source = getattr(parser, 'command_source', None)
-
- self.parameters = []
-
- for action in [a for a in parser._actions if a.help != argparse.SUPPRESS]: # pylint: disable=protected-access
- if action.option_strings:
- self._add_parameter_help(action)
- else:
- # use metavar for positional parameters
- param_kwargs = {
- 'name_source': [action.metavar or action.dest],
- 'deprecate_info': getattr(action, 'deprecate_info', None),
- 'description': action.help,
- 'choices': action.choices,
- 'required': False,
- 'default': None,
- 'group_name': 'Positional'
- }
- self.parameters.append(HelpParameter(**param_kwargs))
-
- help_param = next(p for p in self.parameters if p.name == '--help -h')
- help_param.group_name = 'Global Arguments'
-
- def _load_from_data(self, data):
- super(CliCommandHelpFile, self)._load_from_data(data)
-
- if isinstance(data, str) or not self.parameters or not data.get('parameters'):
- return
-
- loaded_params = []
- loaded_param = {}
- for param in self.parameters:
- loaded_param = next((n for n in data['parameters'] if n['name'] == param.name), None)
- if loaded_param:
- param.update_from_data(loaded_param)
- loaded_params.append(param)
-
- self.parameters = loaded_params
+ super(CliCommandHelpFile, self).__init__(help_ctx, delimiters, parser)
class ArgumentGroupRegistry(KnackArgumentGroupRegistry): # pylint: disable=too-few-public-methods
diff --git a/src/azure-cli-core/azure/cli/core/commands/__init__.py b/src/azure-cli-core/azure/cli/core/commands/__init__.py
index c23aada390a..68d565f0d22 100644
--- a/src/azure-cli-core/azure/cli/core/commands/__init__.py
+++ b/src/azure-cli-core/azure/cli/core/commands/__init__.py
@@ -208,6 +208,7 @@ def execute(self, args):
self.cli_ctx.raise_event(EVENT_INVOKER_PRE_CMD_TBL_TRUNCATE,
load_cmd_tbl_func=self.commands_loader.load_command_table, args=args)
command = self._rudimentary_get_command(args)
+ self.cli_ctx.invocation.data['command_string'] = command
telemetry.set_raw_command_name(command)
try:
@@ -263,7 +264,7 @@ def execute(self, args):
# TODO: No event in base with which to target
telemetry.set_command_details('az')
telemetry.set_success(summary='welcome')
- return None
+ return CommandResultItem(None, exit_code=0)
if args[0].lower() == 'help':
args[0] = '--help'
@@ -340,7 +341,7 @@ def execute(self, args):
except Exception as ex: # pylint: disable=broad-except
if cmd.exception_handler:
cmd.exception_handler(ex)
- return None
+ return CommandResultItem(None, exit_code=1, error=ex)
else:
six.reraise(*sys.exc_info())
@@ -415,25 +416,6 @@ def remove_additional_prop_layer(obj, converted_dic):
converted_dic.update(converted_dic.pop('additionalProperties'))
return converted_dic
- def _rudimentary_get_command(self, args): # pylint: disable=no-self-use
- """ Rudimentary parsing to get the command """
- nouns = []
- command_names = self.commands_loader.command_table.keys()
- for arg in args:
- if arg and arg[0] != '-':
- nouns.append(arg)
- else:
- break
-
- def _find_args(args):
- search = ' '.join(args)
- return next((x for x in command_names if x.startswith(search)), False)
-
- # since the command name may be immediately followed by a positional arg, strip those off
- while nouns and not _find_args(nouns):
- del nouns[-1]
- return ' '.join(nouns)
-
def _validate_cmd_level(self, ns, cmd_validator): # pylint: disable=no-self-use
if cmd_validator:
cmd_validator(**self._build_kwargs(cmd_validator, ns))
diff --git a/src/azure-cli-core/azure/cli/core/commands/parameters.py b/src/azure-cli-core/azure/cli/core/commands/parameters.py
index a136b89d848..11513a29e7a 100644
--- a/src/azure-cli-core/azure/cli/core/commands/parameters.py
+++ b/src/azure-cli-core/azure/cli/core/commands/parameters.py
@@ -320,7 +320,6 @@ def __init__(self, command_loader, scope, **kwargs):
super(AzArgumentContext, self).__init__(command_loader, scope)
self.scope = scope # this is called "command" in knack, but that is not an accurate name
self.group_kwargs = merge_kwargs(kwargs, command_loader.module_kwargs, CLI_PARAM_KWARGS)
- self.is_stale = False
def __enter__(self):
return self
@@ -328,20 +327,6 @@ def __enter__(self):
def __exit__(self, exc_type, exc_val, exc_tb):
self.is_stale = True
- def _applicable(self):
- if self.command_loader.skip_applicability:
- return True
- command_name = self.command_loader.command_name
- scope = self.scope
- return command_name.startswith(scope)
-
- def _check_stale(self):
- if self.is_stale:
- message = "command authoring error: argument context '{}' is stale! " \
- "Check that the subsequent block for has a corresponding `as` statement.".format(self.scope)
- logger.error(message)
- raise CLIError(message)
-
def _flatten_kwargs(self, kwargs, arg_type):
merged_kwargs = self._merge_kwargs(kwargs)
if arg_type:
@@ -390,18 +375,6 @@ def positional(self, dest, arg_type=None, **kwargs):
if not self._applicable():
return
- if self.scope not in self.command_loader.command_table:
- raise ValueError("command authoring error: positional argument '{}' cannot be registered to a group-level "
- "scope '{}'. It must be registered to a specific command.".format(dest, self.scope))
-
- # Before adding the new positional arg, ensure that there are no existing positional arguments
- # registered for this command.
- command_args = self.command_loader.argument_registry.arguments[self.scope]
- positional_args = {k: v for k, v in command_args.items() if v.settings.get('options_list') == []}
- if positional_args and dest not in positional_args:
- raise CLIError("command authoring error: commands may have, at most, one positional argument. '{}' already "
- "has positional argument: {}.".format(self.scope, ' '.join(positional_args.keys())))
-
merged_kwargs = self._flatten_kwargs(kwargs, arg_type)
merged_kwargs = {k: v for k, v in merged_kwargs.items() if k in CLI_POSITIONAL_PARAM_KWARGS}
merged_kwargs['options_list'] = []
@@ -414,7 +387,7 @@ def positional(self, dest, arg_type=None, **kwargs):
min_api=min_api,
max_api=max_api,
operation_group=operation_group):
- super(AzArgumentContext, self).argument(dest, **merged_kwargs)
+ super(AzArgumentContext, self).positional(dest, **merged_kwargs)
else:
self._ignore_if_not_registered(dest)
@@ -485,13 +458,6 @@ def ignore(self, *args):
super(AzArgumentContext, self).ignore(arg)
def extra(self, dest, arg_type=None, **kwargs):
- self._check_stale()
- if not self._applicable():
- return
-
- if self.scope not in self.command_loader.command_table:
- raise ValueError("command authoring error: extra argument '{}' cannot be registered to a group-level "
- "scope '{}'. It must be registered to a specific command.".format(dest, self.scope))
merged_kwargs = self._flatten_kwargs(kwargs, arg_type)
resource_type = merged_kwargs.get('resource_type', None)
@@ -502,5 +468,22 @@ def extra(self, dest, arg_type=None, **kwargs):
min_api=min_api,
max_api=max_api,
operation_group=operation_group):
+ # Restore when knack #132 is fixed
+ # merged_kwargs.pop('dest', None)
+ # super(AzArgumentContext, self).extra(dest, **merged_kwargs)
+ from knack.arguments import CLICommandArgument
+ self._check_stale()
+ if not self._applicable():
+ return
+
+ if self.command_scope in self.command_loader.command_group_table:
+ raise ValueError("command authoring error: extra argument '{}' cannot be registered to a group-level "
+ "scope '{}'. It must be registered to a specific command.".format(
+ dest, self.command_scope))
+
+ deprecate_action = self._handle_deprecations(dest, **merged_kwargs)
+ if deprecate_action:
+ merged_kwargs['action'] = deprecate_action
merged_kwargs.pop('dest', None)
- super(AzArgumentContext, self).extra(argument_dest=dest, **merged_kwargs)
+ self.command_loader.extra_argument_registry[self.command_scope][dest] = CLICommandArgument(
+ dest, **merged_kwargs)
diff --git a/src/azure-cli-core/azure/cli/core/file_util.py b/src/azure-cli-core/azure/cli/core/file_util.py
index a90667dc62e..d789a0bb494 100644
--- a/src/azure-cli-core/azure/cli/core/file_util.py
+++ b/src/azure-cli-core/azure/cli/core/file_util.py
@@ -14,7 +14,7 @@ def get_all_help(cli_ctx):
invoker = cli_ctx.invocation
help_ctx = cli_ctx.help_cls(cli_ctx)
if not invoker:
- raise CLIError("CLI context does not contain invocation.")
+ raise CLIError('CLI context does not contain invocation.')
parser_keys = []
parser_values = []
@@ -45,14 +45,21 @@ def create_invoker_and_load_cmds_and_args(cli_ctx):
invoker = cli_ctx.invocation_cls(cli_ctx=cli_ctx, commands_loader_cls=cli_ctx.commands_loader_cls,
parser_cls=cli_ctx.parser_cls, help_cls=cli_ctx.help_cls)
cli_ctx.invocation = invoker
+ invoker.commands_loader.skip_applicability = True
invoker.commands_loader.load_command_table(None)
+
+ # turn off applicability check for all loaders
+ for loaders in invoker.commands_loader.cmd_to_loader_map.values():
+ for loader in loaders:
+ loader.skip_applicability = True
+
for command in invoker.commands_loader.command_table:
invoker.commands_loader.load_arguments(command)
- invoker.parser.load_command_table(invoker.commands_loader)
register_global_subscription_argument(cli_ctx)
register_ids_argument(cli_ctx) # global subscription must be registered first!
cli_ctx.raise_event(events.EVENT_INVOKER_POST_CMD_TBL_CREATE, commands_loader=invoker.commands_loader)
+ invoker.parser.load_command_table(invoker.commands_loader)
def _store_parsers(parser, parser_keys, parser_values, sub_parser_keys, sub_parser_values):
diff --git a/src/azure-cli-core/azure/cli/core/parser.py b/src/azure-cli-core/azure/cli/core/parser.py
index 8f606c7998c..ff7e58fe554 100644
--- a/src/azure-cli-core/azure/cli/core/parser.py
+++ b/src/azure-cli-core/azure/cli/core/parser.py
@@ -11,7 +11,6 @@
import argparse
import argcomplete
-from knack.deprecation import Deprecated
from knack.log import get_logger
from knack.parser import CLICommandParser
from knack.util import CLIError
@@ -186,36 +185,3 @@ def _check_value(self, action, value):
print(suggestion_msg, file=sys.stderr)
self.exit(2)
-
- @staticmethod
- def _add_argument(obj, arg):
- """ Only pass valid argparse kwargs to argparse.ArgumentParser.add_argument """
- from knack.parser import ARGPARSE_SUPPORTED_KWARGS
-
- argparse_options = {name: value for name, value in arg.options.items() if name in ARGPARSE_SUPPORTED_KWARGS}
- if arg.options_list:
-
- scrubbed_options_list = []
- for item in arg.options_list:
-
- if isinstance(item, Deprecated):
- # don't add expired options to the parser
- if item.expired():
- continue
-
- class _DeprecatedOption(str):
- def __new__(cls, *args, **kwargs):
- instance = str.__new__(cls, *args, **kwargs)
- return instance
-
- option = _DeprecatedOption(item.target)
- setattr(option, 'deprecate_info', item)
- item = option
- scrubbed_options_list.append(item)
- return obj.add_argument(*scrubbed_options_list, **argparse_options)
- else:
- if 'required' in argparse_options:
- del argparse_options['required']
- if 'metavar' not in argparse_options:
- argparse_options['metavar'] = '<{}>'.format(argparse_options['dest'].upper())
- return obj.add_argument(**argparse_options)
diff --git a/src/azure-cli-core/setup.py b/src/azure-cli-core/setup.py
index 06e1e02fe7e..6d12201a29a 100644
--- a/src/azure-cli-core/setup.py
+++ b/src/azure-cli-core/setup.py
@@ -59,7 +59,7 @@
'colorama>=0.3.9',
'humanfriendly>=4.7',
'jmespath',
- 'knack==0.4.5',
+ 'knack==0.5.1',
'msrest>=0.4.4',
'msrestazure>=0.4.25',
'paramiko>=2.0.8',
diff --git a/src/command_modules/azure-cli-keyvault/azure/cli/command_modules/keyvault/_params.py b/src/command_modules/azure-cli-keyvault/azure/cli/command_modules/keyvault/_params.py
index b2a81e4a5df..787d480f894 100644
--- a/src/command_modules/azure-cli-keyvault/azure/cli/command_modules/keyvault/_params.py
+++ b/src/command_modules/azure-cli-keyvault/azure/cli/command_modules/keyvault/_params.py
@@ -102,7 +102,10 @@ def load_arguments(self, _):
for cmd in ['backup', 'delete', 'download', 'set-attributes', 'show']:
with self.argument_context('keyvault {} {}'.format(item, cmd), arg_group='Id') as c:
- c.extra('identifier', options_list=['--id'], help='Id of the {}. If specified all other \'Id\' arguments should be omitted.'.format(item), validator=validate_vault_id(item))
+ try:
+ c.extra('identifier', options_list=['--id'], help='Id of the {}. If specified all other \'Id\' arguments should be omitted.'.format(item), validator=validate_vault_id(item))
+ except ValueError:
+ pass
c.argument(item + '_name', help='Name of the {}. Required if --id is not specified.'.format(item), required=False)
c.argument('vault_base_url', help='Name of the key vault. Required if --id is not specified.', required=False)
c.argument(item + '_version', required=False)
diff --git a/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/__init__.py b/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/__init__.py
index 21767a30e6b..69288362b43 100644
--- a/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/__init__.py
+++ b/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/__init__.py
@@ -216,7 +216,7 @@ def _register_data_plane_oauth_arguments(self, command_name):
# The following code bypasses those checks, as these arguments are registered in tandem with commands.
if command_name not in self.command_loader.command_table:
return
- self.command_loader.command_name = command_name
+ self.command_loader.cli_ctx.invocation.data['command_string'] = command_name
with self.command_loader.argument_context(command_name, min_api='2017-11-09') as c:
c.extra('auth_mode', arg_type=get_enum_type(['login', 'key']),