Skip to content
8 changes: 8 additions & 0 deletions src/azure-cli/azure/cli/command_modules/vm/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,10 @@
- name: Add a customScript extension to VM(s) specified by --ids.
text: |
az vm extension set -n customScript --publisher Microsoft.Azure.Extensions --ids {vm_id}
- name: Add an extension and enable automatic upgrade by the platform if there is a newer version of the extension available.
text: |
az vm extension set -n extName --publisher publisher --vm-name MyVM -g MyResourceGroup \\
--enable-auto-upgrade true
parameters:
- name: --name -n
populator-commands:
Expand Down Expand Up @@ -2462,6 +2466,10 @@
--version 2.0 --publisher Microsoft.Azure.Extensions \\
--provision-after-extensions NetworkWatcherAgentLinux VMAccessForLinux \\
--settings '{"commandToExecute": "echo testing"}'
- name: Add an extension and enable automatic upgrade by the platform if there is a newer version of the extension available.
text: >
az vmss extension set -n extName --publisher publisher --vmss-name my-vmss -g my-group \\
--enable-auto-upgrade true
"""

helps['vmss extension show'] = """
Expand Down
9 changes: 7 additions & 2 deletions src/azure-cli/azure/cli/command_modules/vm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,10 @@ def load_arguments(self, _):
# region VM & VMSS Shared
for scope in ['vm', 'vmss']:
with self.argument_context(scope) as c:
c.argument('no_auto_upgrade', arg_type=get_three_state_flag(), help='If set, the extension service will not automatically pick or upgrade to the latest minor version, even if the extension is redeployed.')
c.argument('no_auto_upgrade',
options_list=['--no-auto-upgrade-minor-version', c.deprecate(target='--no-auto-upgrade', redirect='--no-auto-upgrade-minor-version')],
arg_type=get_three_state_flag(),
help='If set, the extension service will not automatically pick or upgrade to the latest minor version, even if the extension is redeployed.')

with self.argument_context('{} run-command'.format(scope)) as c:
c.argument('command_id', completer=get_vm_run_command_completion_list, help="The command id. Use 'az {} run-command list' to get the list".format(scope))
Expand Down Expand Up @@ -781,7 +784,9 @@ def load_arguments(self, _):
c.argument('publisher', help='The name of the extension publisher.')
c.argument('settings', type=validate_file_or_dict, help='Extension settings in JSON format. A JSON file path is also accepted.')
c.argument('protected_settings', type=validate_file_or_dict, help='Protected settings in JSON format for sensitive information like credentials. A JSON file path is also accepted.')
c.argument('version', help='The version of the extension. To pin extension version to this value, please specify --no-auto-upgrade.')
c.argument('version', help='The version of the extension. To pin extension version to this value, please specify --no-auto-upgrade-minor-version.')
c.argument('enable_auto_upgrade', arg_type=get_three_state_flag(),
help='Indicate the extension should be automatically upgraded by the platform if there is a newer version of the extension available.')

with self.argument_context('vm extension set') as c:
c.argument('vm_extension_name', name_arg_type,
Expand Down
11 changes: 7 additions & 4 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ def list_extensions(cmd, resource_group_name, vm_name):

def set_extension(cmd, resource_group_name, vm_name, vm_extension_name, publisher, version=None, settings=None,
protected_settings=None, no_auto_upgrade=False, force_update=False, no_wait=False,
extension_instance_name=None):
extension_instance_name=None, enable_auto_upgrade=None):
vm = get_vm(cmd, resource_group_name, vm_name, 'instanceView')
client = _compute_client_factory(cmd.cli_ctx)

Expand All @@ -1636,7 +1636,8 @@ def set_extension(cmd, resource_group_name, vm_name, vm_extension_name, publishe
protected_settings=protected_settings,
type_handler_version=version,
settings=settings,
auto_upgrade_minor_version=(not no_auto_upgrade))
auto_upgrade_minor_version=(not no_auto_upgrade),
enable_automatic_upgrade=enable_auto_upgrade)
if force_update:
ext.force_update_tag = str(_gen_guid())
return sdk_no_wait(no_wait, client.virtual_machine_extensions.begin_create_or_update,
Expand Down Expand Up @@ -3086,7 +3087,8 @@ def list_vmss_extensions(cmd, resource_group_name, vmss_name):

def set_vmss_extension(cmd, resource_group_name, vmss_name, extension_name, publisher, version=None,
settings=None, protected_settings=None, no_auto_upgrade=False, force_update=False,
no_wait=False, extension_instance_name=None, provision_after_extensions=None):
no_wait=False, extension_instance_name=None, provision_after_extensions=None,
enable_auto_upgrade=None):
if not extension_instance_name:
extension_instance_name = extension_name

Expand All @@ -3113,7 +3115,8 @@ def set_vmss_extension(cmd, resource_group_name, vmss_name, extension_name, publ
type_handler_version=version,
settings=settings,
auto_upgrade_minor_version=(not no_auto_upgrade),
provision_after_extensions=provision_after_extensions)
provision_after_extensions=provision_after_extensions,
enable_automatic_upgrade=enable_auto_upgrade)
if force_update:
ext.force_update_tag = str(_gen_guid())

Expand Down
Loading