Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
fd6af49
{ARO} add __init__.py for ARO tests and update recording (#13089)
Apr 20, 2020
ad2a70f
{Profile} az login: Polish UnicodeDecodeError (#12972)
jiasli Apr 20, 2020
8937383
{Aladdin} add usage examples for module: monitor network privatedns r…
Apr 20, 2020
66fe624
[Compute] az vmss disk detach: fix data disk NoneType issue (#13069)
arrownj Apr 20, 2020
2989946
[ARO] Fixed az aro table output bug (#13066)
m1kola Apr 20, 2020
758f7e9
fix CI (#13114)
mmyyrroonn Apr 22, 2020
9abb510
[Core] fix logging file fd leaking (#13102)
Apr 22, 2020
0ae790c
[AppService] remove sleep after request.get() (#12609)
bmc-msft Apr 22, 2020
2862ce5
[Network] az network security-partner: support security partner provi…
mmyyrroonn Apr 22, 2020
89cf88c
[KeyVault] Add new parameter `--enable-rbac-authorization` during cre…
bim-msft Apr 22, 2020
21172d9
[AKS] az aks create: Add support for Windows (#13084)
AbelHu Apr 23, 2020
facd2bd
fix ci (#13132)
mmyyrroonn Apr 23, 2020
b3d6fb7
{ACR} Fix small typos (#13142)
pablomh Apr 24, 2020
fdc155c
{Compute} Delete stale test of image builder (#13134)
qwordy Apr 24, 2020
12367f8
rename (#13147)
mmyyrroonn Apr 24, 2020
4a58bcb
[Core] fix core tests failed under certain profiles (#13136)
Apr 24, 2020
b93fab1
[Privatedns] Add feature in private DNS zone to import export zone fi…
rahisshaikh Apr 26, 2020
d10679e
{Resource} Remove resource test test_resource_policyset from profile …
Apr 26, 2020
f4ff610
[Monitor] Support LA cluster CMK features (#13133)
jsntcy Apr 26, 2020
80c7bc7
{Core} support get msal accesstoken with adal refresh token for vm ss…
arrownj Apr 26, 2020
4e1ed61
{REST} az rest: Refine help (#13067)
jiasli Apr 26, 2020
dada5c0
{Compute} Update doc of image-version (#13112)
qwordy Apr 27, 2020
5fff003
[Compute] az vm availability-set list: Support showing VM list (#13090)
qwordy Apr 27, 2020
32e5102
[ACS] BREAKING CHANGE: ARO remove vnet-peer, upgrade to 2019-10-27-pr…
Apr 27, 2020
984817c
[Compute] az vm list-skus: Fix display problem of table format (#13184)
qwordy Apr 27, 2020
79964fb
[Monitor] az monitor log-analytics workspace linked-storage: supports…
mmyyrroonn Apr 27, 2020
d261ede
[CI] Onboard pytest and deprecate nose for Automation Test (#13153)
Apr 27, 2020
a638130
[ARM] az deployment sub/group what-if:Add new commands to support Wha…
shenglol Apr 27, 2020
44c3b4a
[Core] Unpin wheel version via pkginfo to query metadata for Python P…
Apr 27, 2020
06cce5b
revert wheel to 0.30.0 (#13198)
Apr 27, 2020
2349420
update azure-cli version to 2.5.0 (#13206)
Apr 28, 2020
37fcdc6
fix style (#13218)
Juliehzl Apr 28, 2020
69c9933
{CI} Fix running full test timeout on profile when in batch mode (#13…
Apr 28, 2020
21e8a2c
upgrade package (#13183)
Juliehzl Apr 28, 2020
cf7f852
[Storage] Support GZRS for storage account creation and update (#13196)
Juliehzl Apr 28, 2020
015be59
[SQL] `az sql instance-pool`: Add instance pools command group (#11721)
rohands Apr 28, 2020
c8edc08
re-run (#13224)
mmyyrroonn Apr 28, 2020
d60ceda
[Compute] vm list-ip-addresses: Error handling (#13186)
qwordy Apr 28, 2020
35c140c
{Network} fix duplicated quotes for private-endpoint example (#13227)
Apr 28, 2020
91f91cc
[Extension] fix loading wrong metadata for wheel type extension (#13222)
Apr 28, 2020
3315616
[Cosmos DB] az cosmosdb create/update: add --enable-public-network su…
soeom Apr 28, 2020
16de64f
[ACR] `az acr check-health`: Fix "DOCKER_PULL_ERROR" on Windows (#13158)
Wwwsylvia Apr 29, 2020
b302f30
[Compute] Fix a bug of vm create if endpoint_vm_image_alias_doc is no…
qwordy Apr 29, 2020
868decc
[Packaging] Add az script for Git Bash/Cygwin on Windows (#13197)
fengzhou-msft Apr 29, 2020
154ecaa
[Compute] vmss create: Add --os-disk-size-gb (#13180)
qwordy Apr 29, 2020
1d64349
{Packaging} Remove wheel as a runtime dependency (#13230)
fengzhou-msft Apr 29, 2020
bd8a963
[Storage] `az storage account failover`: Add support for grs/gzrs sto…
Juliehzl Apr 30, 2020
4acf761
{Extension} Enhance the ability to filter extension's dist-info in or…
Apr 30, 2020
6fc125b
[Storage] `az storage blob upload`: Add --encryption-scope parameter …
Juliehzl Apr 30, 2020
c8bb769
upgarde version (#13265)
Juliehzl Apr 30, 2020
ba399c7
{Release} Upgrade to Azure CLI 2.5.1 (#13263)
Apr 30, 2020
527267b
{Profile} az login: In WSL use powershell.exe to open the default bro…
jiasli Apr 30, 2020
2aa71a7
pass test for connection string (#13273)
Juliehzl Apr 30, 2020
44c092a
{Config} Add endpoint suffix for mysql and postgre sql (#13115)
handsomesun May 6, 2020
f4f44bd
[AppService] functionapp: AzureWebJobsDashboard will only be set if A…
gzuber May 6, 2020
b7a41a3
fix in enable protection for fileshare cmd (#13268)
May 6, 2020
066ca6e
Fix in restore flow (#13348)
May 6, 2020
2325d7c
{Docs} Quote code in help messages with backticks (#13060)
jiasli May 6, 2020
7674236
[Extension] Support installing extensions in a system directory (#12856)
fengzhou-msft May 6, 2020
2343260
[AppService] fix #10664- VNet Integration - Location Check Issue & fi…
Kotasudhakarreddy May 6, 2020
7a087b1
[IoT] Update the IoT command module first run extension awareness mes…
digimaun May 7, 2020
949aaa0
[Network] fix ttl value changed unintended for dns add-record (#13243)
May 7, 2020
e6a19f2
[Compute] New command az vm auto-shutdown (#13199)
qwordy May 7, 2020
a2ab44e
refine help message (#13372)
mmyyrroonn May 7, 2020
cd405fa
ACS: remove fields cleanup that no longer exist (#13315)
May 7, 2020
da047a1
[AKS] update uptime-sla command help context (#13300)
zqingqing1 May 7, 2020
a6fc7da
[Extension] support .egg-info to store wheel type extension metadata …
May 7, 2020
26e341b
[AppConfig] Bug fix for list key values with fields (#13326)
shenmuxiaosen May 7, 2020
df10af0
{AppService}: Updating websites to use the latest SDK version (#13328)
panchagnula May 7, 2020
cef3cf4
{CI} temporary disable CredScan since ADO bug (#13388)
May 8, 2020
f2fa95a
acr: add timeout of 5 minutes (#13349)
yugangw-msft May 8, 2020
08328cd
{Packaging} Clean some azure-cli dependencies (#13253)
fengzhou-msft May 8, 2020
c3f32ed
[ACR] Support disable public network access (#13347)
yugangw-msft May 8, 2020
aa9c4c1
[ARM] az deployment: Fix the problem that the templateLink will not b…
zhoxing-ms May 8, 2020
2de661c
{Storage} Use get_login_credentials from Core for --auth-mode login i…
Juliehzl May 8, 2020
28cc8f4
Bump ADAL version to 1.2.3 (#13371)
jiasli May 8, 2020
4b495b0
[Network] az network public-ip create: Inform customers of a coming b…
jsntcy May 8, 2020
a15c836
[ARO] Add examples to az aro create, list, list-credentials, show, de…
troy0820 May 9, 2020
f04507a
Update python SDK (#13287)
soeom May 9, 2020
14ecf9e
[Storage] az storage account file-service-properties update/show: Add…
Juliehzl May 9, 2020
05d6f12
[ACR]: bug fixes on token create and image import commands (#13392)
yugangw-msft May 9, 2020
137fcc8
{CI} Allow CI to pass on fork repos (#13398)
jiasli May 9, 2020
193c17c
{Docs} Documentation update for configuring machine in VS Code (#13239)
niswitze May 9, 2020
3c8bf29
Fixes az openshift show command (#13358)
m1kola May 9, 2020
5f3c3da
Fix the problem that deployment does not support specially encoded ch…
zhoxing-ms May 9, 2020
70bedda
{Compute} az vm auto-shutdown: remove a validation (#13409)
qwordy May 11, 2020
938bbaf
[RBAC] `az ad sp credential reset`: fix weak credential generation (#…
qianwens May 11, 2020
0caf144
[Network] support generic commands for private link scenario (#13225)
mmyyrroonn May 11, 2020
bd3dfd5
[Network] az network private-endpoint-connection: Support mysql, post…
mmyyrroonn May 11, 2020
197fcf6
acr: keep show-endpoints command in preview (#13430)
yugangw-msft May 11, 2020
0fc82ed
[AMS] Change az ams transform create and az ams content-key-policy cr…
hivyas May 12, 2020
827774b
[Packaging] Build MSI/Homebrew packages with dependecies resolved fro…
fengzhou-msft May 12, 2020
fce911e
[CI] Support flake8 3.8.0 (#13454)
May 12, 2020
b465b2a
{Docs} Increase visibility of doc/use_cli_effectively.md (#13249)
jiasli May 13, 2020
50a18e8
[Network] az network private-endpoint-connection: Support cosmosdb ty…
mmyyrroonn May 13, 2020
0ce0448
[Core] Update local context on/off status to global user level (#13277)
arrownj May 13, 2020
830672d
remove range check for updating min count for autoscaler (#13215)
marwanad May 13, 2020
c07a398
{CI} Code style check use latest azdev (#13450)
May 13, 2020
fe18bc1
[AppService] az webapp|functionapp config ssl import: Lookup key vaul…
madsd May 14, 2020
df5cfde
{CI} Re-enable CredScan (#13464)
May 14, 2020
39c0d01
[ARM] az deployment sub/group what-if: Fix array alignment and error …
shenglol May 14, 2020
3d1fc80
change sappservice code (#13412)
Juliehzl May 14, 2020
f629608
{ACR} Use azure.multiapi.storage for storage blob service (#13411)
Juliehzl May 14, 2020
bcb9921
{batchai} Change storage dependency (#13414)
Juliehzl May 14, 2020
a6a469f
{TestSDK} Delete local context file when local context scenario test …
arrownj May 14, 2020
8f149eb
[ARO]Add generate_random_id function (#13482)
troy0820 May 14, 2020
863517e
{Resource} Remove unused f-string to fix code style (#13493)
May 14, 2020
8027e06
{Doc} Add quoting-issues-with-powershell.md (#13419)
jiasli May 14, 2020
989924e
{Core} Load vnet/subnet global definition for local context by defaul…
arrownj May 14, 2020
a70d7db
Added "MAB" backupmanagementtype to item list command (#13449)
May 14, 2020
ca63e5d
[Backup] Add support for retrying policy update for failed items. (#1…
May 14, 2020
28b1422
[Backup] Add Resume Protection functionality for Azure Virtual Machin…
May 14, 2020
2c3097b
[Backup] Add support to specify ResourceGroup for storing instantRP d…
May 14, 2020
73ee5ce
[Storage] `az storage container create`: Fix #13373 by adding validat…
Juliehzl May 14, 2020
e6e437a
[Output] Show update instruction in find, feedback and --help (#13345)
fengzhou-msft May 14, 2020
2439cc8
[Storage] Add ADLS Gen2 track2 support (#12729)
Juliehzl May 15, 2020
50cedea
{ACR}: expose --expiration from token commands (#13451)
yugangw-msft May 15, 2020
f7e6bba
Fix that cli doe not fail when user only specifies Windows password (…
AbelHu May 15, 2020
cb927d5
[Compute] az vm list-skus: Update --zone behavior, return all type sk…
qwordy May 15, 2020
58198af
[IoT Hub] Support for 2020-03-01 API and Network Isolation commands (…
c-ryan-k May 15, 2020
2e850ea
{Monitor} az monitor metrics alert: refine severity explanation (#13512)
mmyyrroonn May 15, 2020
80457eb
[AppService] Onboard local context for app service (#12984)
arrownj May 15, 2020
4d73f0f
Modify the deprecate information for deployment operation (#13390)
zhoxing-ms May 15, 2020
08432df
Support --connect-string for az storage blob sync (#13135)
zhoxing-ms May 15, 2020
9b71e8a
[Storage] az storage blob sync: Fix the incorrect error message when …
zhoxing-ms May 15, 2020
bae215b
{Network} az network nic create: Refine help message (#13513)
mmyyrroonn May 15, 2020
ee84afb
[NetAppFiles] Anf 5207 Bugfix - add missing snapshot restore function…
audunn May 15, 2020
fe1e042
{Resource} Add example to tell how to pass array to --parameters (#13…
May 16, 2020
530cd07
fix (#13511)
mmyyrroonn May 18, 2020
029e73b
{Release} Upgrade to Azure CLI 2.6.0 (#13542)
May 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Core] Update local context on/off status to global user level (#13277)
* [Core] update local context to global user level

* [Configure] az local-context: add list/show/delete/clear command

* {Network} refactor for local context

* {Resource} refactor for local context

* add LocalContextScenarioTest

* add vnet/subnet type definiton for local context

* remove unused file

* update default_from to default_value_source

* update knack version to 0.7.0

* drop using get_config_parser from knack

* fix CI error

* upgrade knack to 0.7.1

* fix CI error

* fix CI error

* fix sytle error

* fix style error

* update --subnet-name to --subnet

* fix review problems

* fix style error

* load local context file only when it is turned on

* add wanrning message when save to local context
  • Loading branch information
arrownj authored May 13, 2020
commit 0ce0448c9cbe73faa26c56ffcc9bc10bbf3b30f2
23 changes: 17 additions & 6 deletions src/azure-cli-core/azure/cli/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from knack.experimental import ExperimentalItem
from knack.util import CLIError
from knack.arguments import ArgumentsContext, CaseInsensitiveList # pylint: disable=unused-import
from .local_context import AzCLILocalContext, SET
from .local_context import AzCLILocalContext, LocalContextAction

logger = get_logger(__name__)

Expand Down Expand Up @@ -69,9 +69,7 @@ def __init__(self, **kwargs):
SESSION.load(os.path.join(azure_folder, 'az.sess'), max_age=3600)
self.cloud = get_active_cloud(self)
logger.debug('Current cloud config:\n%s', str(self.cloud.name))
self.local_context = AzCLILocalContext(
dir_name=os.path.basename(self.config.config_dir), file_name='local_context'
)
self.local_context = AzCLILocalContext(self)
register_global_transforms(self)
register_global_subscription_argument(self)
register_ids_argument(self) # global subscription must be registered first!
Expand Down Expand Up @@ -162,20 +160,33 @@ def save_local_context(self, parsed_args, argument_definitions, specified_argume
:param specified_arguments: Arguments which user specify in this command
:type specified_arguments: list
"""

local_context_args = []
for argument_name in specified_arguments:
# make sure SET is defined
if argument_name not in argument_definitions:
continue
argtype = argument_definitions[argument_name].type
lca = argtype.settings.get('local_context_attribute', None)
if not lca or not lca.actions or SET not in lca.actions:
if not lca or not lca.actions or LocalContextAction.SET not in lca.actions:
continue
# get the specified value
value = getattr(parsed_args, argument_name)
# save when name and scopes have value
if lca.name and lca.scopes:
self.local_context.set(lca.scopes, lca.name, value)
options = argtype.settings.get('options_list', None)
if options:
local_context_args.append((options[0], value))

# print warning if there are values saved to local context
if local_context_args:
logger.warning('Local context is turned on. Its information is saved in working directory %s. You can '
'run `az local-context off` to turn it off.',
self.local_context.effective_working_directory())
args_str = []
for name, value in local_context_args:
args_str.append('{}: {}'.format(name, value))
logger.warning('Command argument values saved to local context: %s', ', '.join(args_str))


class MainCommandsLoader(CLICommandsLoader):
Expand Down
23 changes: 13 additions & 10 deletions src/azure-cli-core/azure/cli/core/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,25 @@ def _print_detailed_help(self, cli_name, help_file):

@staticmethod
def _get_choices_defaults_sources_str(p):
choice_str = u' Allowed values: {}.'.format(', '.join(sorted([str(x) for x in p.choices]))) \
choice_str = ' Allowed values: {}.'.format(', '.join(sorted([str(x) for x in p.choices]))) \
if p.choices else ''
default_str = u' Default: {}.'.format(p.default) if p.default and p.default != argparse.SUPPRESS else ''
default_value_source = p.default_value_source if p.default_value_source else 'Default'
default_str = ' {}: {}.'.format(default_value_source, p.default) \
if p.default and p.default != argparse.SUPPRESS else ''
value_sources_str = CLIPrintMixin._process_value_sources(p) if p.value_sources else ''
return u'{}{}{}'.format(choice_str, default_str, value_sources_str)
return '{}{}{}'.format(choice_str, default_str, value_sources_str)

@staticmethod
def _print_examples(help_file):
indent = 0
_print_indent('Examples', indent)
for e in help_file.examples:
indent = 1
_print_indent(u'{0}'.format(e.short_summary), indent)
_print_indent('{0}'.format(e.short_summary), indent)
indent = 2
if e.long_summary:
_print_indent(u'{0}'.format(e.long_summary), indent)
_print_indent(u'{0}'.format(e.command), indent)
_print_indent('{0}'.format(e.long_summary), indent)
_print_indent('{0}'.format(e.command), indent)
print('')

@staticmethod
Expand All @@ -109,11 +111,11 @@ def _process_value_sources(p):
elif "link" in item and "url" in item["link"]:
urls.append(item["link"]["url"])

command_str = u' Values from: {}.'.format(", ".join(commands)) if commands else ''
string_str = u' {}'.format(", ".join(strings)) if strings else ''
command_str = ' Values from: {}.'.format(", ".join(commands)) if commands else ''
string_str = ' {}'.format(", ".join(strings)) if strings else ''
string_str = string_str + "." if string_str and not string_str.endswith(".") else string_str
urls_str = u' For more info, go to: {}.'.format(", ".join(urls)) if urls else ''
return u'{}{}{}'.format(command_str, string_str, urls_str)
urls_str = ' For more info, go to: {}.'.format(", ".join(urls)) if urls else ''
return '{}{}{}'.format(command_str, string_str, urls_str)

@staticmethod
def _print_extensions_msg(help_file):
Expand Down Expand Up @@ -301,6 +303,7 @@ def __init__(self, help_ctx, delimiters, parser):
'deprecate_info': getattr(action, 'deprecate_info', None),
'preview_info': getattr(action, 'preview_info', None),
'experimental_info': getattr(action, 'experimental_info', None),
'default_value_source': getattr(action, 'default_value_source', None),
'description': action.help,
'choices': action.choices,
'required': False,
Expand Down
13 changes: 6 additions & 7 deletions src/azure-cli-core/azure/cli/core/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
import os
import json
from pprint import pformat
from six.moves import configparser
import configparser

from azure.cli.core.profiles import API_PROFILES
from azure.cli.core._config import GLOBAL_CONFIG_DIR
from azure.cli.core.util import urlretrieve

from knack.log import get_logger
from knack.util import CLIError
from knack.config import get_config_parser

logger = get_logger(__name__)

Expand Down Expand Up @@ -381,7 +380,7 @@ def _get_cloud_name(cli_ctx, cloud_name):

def get_clouds(cli_ctx):
clouds = []
config = get_config_parser()
config = configparser.ConfigParser()
# Start off with known clouds and apply config file on top of current config
for c in KNOWN_CLOUDS:
_config_add_cloud(config, c)
Expand Down Expand Up @@ -438,7 +437,7 @@ def get_active_cloud(cli_ctx=None):


def get_cloud_subscription(cloud_name):
config = get_config_parser()
config = configparser.ConfigParser()
config.read(CLOUD_CONFIG_FILE)
try:
return config.get(cloud_name, 'subscription')
Expand All @@ -449,7 +448,7 @@ def get_cloud_subscription(cloud_name):
def set_cloud_subscription(cli_ctx, cloud_name, subscription):
if not _get_cloud(cli_ctx, cloud_name):
raise CloudNotRegisteredException(cloud_name)
config = get_config_parser()
config = configparser.ConfigParser()
config.read(CLOUD_CONFIG_FILE)
if subscription:
try:
Expand Down Expand Up @@ -519,7 +518,7 @@ def _config_add_cloud(config, cloud, overwrite=False):


def _save_cloud(cloud, overwrite=False):
config = get_config_parser()
config = configparser.ConfigParser()
config.read(CLOUD_CONFIG_FILE)
_config_add_cloud(config, cloud, overwrite=overwrite)
if not os.path.isdir(GLOBAL_CONFIG_DIR):
Expand Down Expand Up @@ -550,7 +549,7 @@ def remove_cloud(cli_ctx, cloud_name):
if is_known_cloud:
raise CannotUnregisterCloudException("The cloud '{}' cannot be unregistered "
"as it's not a custom cloud.".format(cloud_name))
config = get_config_parser()
config = configparser.ConfigParser()
config.read(CLOUD_CONFIG_FILE)
config.remove_section(cloud_name)
with open(CLOUD_CONFIG_FILE, 'w') as configfile:
Expand Down
31 changes: 27 additions & 4 deletions src/azure-cli-core/azure/cli/core/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
AzArgumentContext, patch_arg_make_required, patch_arg_make_optional)
from azure.cli.core.extension import get_extension
from azure.cli.core.util import get_command_type_kwarg, read_file_content, get_arg_list, poller_classes
from azure.cli.core.local_context import GET
from azure.cli.core.local_context import LocalContextAction
import azure.cli.core.telemetry as telemetry


Expand Down Expand Up @@ -293,9 +293,9 @@ def _resolve_default_value_from_config_file(self, arg, overrides):
self._resolve_default_value_from_local_context(arg, overrides)

def _resolve_default_value_from_local_context(self, arg, overrides):
if self.cli_ctx.local_context.is_on():
if self.cli_ctx.local_context.is_on:
lca = overrides.settings.get('local_context_attribute', None)
if not lca or not lca.actions or GET not in lca.actions:
if not lca or not lca.actions or LocalContextAction.GET not in lca.actions:
return
if lca.name:
local_context = self.cli_ctx.local_context
Expand All @@ -304,6 +304,7 @@ def _resolve_default_value_from_local_context(self, arg, overrides):
logger.debug("local context '%s' for arg %s", value, arg.name)
overrides.settings['default'] = DefaultStr(value)
overrides.settings['required'] = False
overrides.settings['default_value_source'] = 'Local Context'

def load_arguments(self):
super(AzCliCommand, self).load_arguments()
Expand Down Expand Up @@ -578,6 +579,28 @@ def execute(self, args):
parsed_args = self.parser.parse_args(args)
self.cli_ctx.raise_event(EVENT_INVOKER_POST_PARSE_ARGS, command=parsed_args.command, args=parsed_args)

# print local context warning
if self.cli_ctx.local_context.is_on and command and command in self.commands_loader.command_table:
local_context_args = []
arguments = self.commands_loader.command_table[command].arguments
specified_arguments = self.parser.subparser_map[command].specified_arguments \
if command in self.parser.subparser_map else []
for name, argument in arguments.items():
default_value_source = argument.type.settings.get('default_value_source', None)
dest_name = argument.type.settings.get('dest', None)
options = argument.type.settings.get('options_list', None)
if default_value_source == 'Local Context' and dest_name not in specified_arguments and options:
value = getattr(parsed_args, name)
local_context_args.append((options[0], value))
if local_context_args:
logger.warning('Local context is turned on. Its information is saved in working directory %s. You can '
'run `az local-context off` to turn it off.',
self.cli_ctx.local_context.effective_working_directory())
args_str = []
for name, value in local_context_args:
args_str.append('{}: {}'.format(name, value))
logger.warning('Command argument values from local context: %s', ', '.join(args_str))

# TODO: This fundamentally alters the way Knack.invocation works here. Cannot be customized
# with an event. Would need to be customized via inheritance.

Expand Down Expand Up @@ -643,7 +666,7 @@ def execute(self, args):
self.cli_ctx.raise_event(EVENT_INVOKER_FILTER_RESULT, event_data=event_data)

# save to local context if it is turned on after command executed successfully
if self.cli_ctx.local_context.is_on() and command and command in self.commands_loader.command_table and \
if self.cli_ctx.local_context.is_on and command and command in self.commands_loader.command_table and \
command in self.parser.subparser_map and self.parser.subparser_map[command].specified_arguments:
self.cli_ctx.save_local_context(parsed_args, self.commands_loader.command_table[command].arguments,
self.parser.subparser_map[command].specified_arguments)
Expand Down
18 changes: 16 additions & 2 deletions src/azure-cli-core/azure/cli/core/commands/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from azure.cli.core.commands.validators import validate_tag, validate_tags, generate_deployment_name
from azure.cli.core.decorators import Completer
from azure.cli.core.profiles import ResourceType
from azure.cli.core.local_context import LocalContextAttribute, SET, GET, ALL
from azure.cli.core.local_context import LocalContextAttribute, LocalContextAction, ALL

from knack.arguments import (
CLIArgumentType, CaseInsensitiveList, ignore_type, ArgumentsContext)
Expand Down Expand Up @@ -242,7 +242,7 @@ def _type(value):
configured_default='group',
local_context_attribute=LocalContextAttribute(
name='resource_group_name',
actions=[SET, GET],
actions=[LocalContextAction.SET, LocalContextAction.GET],
scopes=[ALL]
))

Expand Down Expand Up @@ -303,6 +303,20 @@ def get_location_type(cli_ctx):
nargs=1
)

vnet_name_type = CLIArgumentType(
options_list='--vnet-name',
metavar='NAME',
help='The virtual network (VNet) name.',
completer=get_resource_name_completion_list('Microsoft.Network/virtualNetworks'),
local_context_attribute=LocalContextAttribute(name='vnet_name', actions=[LocalContextAction.GET])
)

subnet_name_type = CLIArgumentType(
options_list='--subnet',
metavar='NAME',
help='The subnet name.',
local_context_attribute=LocalContextAttribute(name='subnet_name', actions=[LocalContextAction.GET]))


def patch_arg_make_required(argument):
argument.settings['required'] = True
Expand Down
Loading