Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
examples:
- name: Add a new linux user
text:
az vm extension set -n VMAccessForLinux --publisher Microsoft.OSTCExtensions --version 1.4 --vm-name myvm --resource-group mygroup --private-config '{"username":"user1", "ssh_key":"ssh_rsa ..."}'
az vm extension set -n VMAccessForLinux --publisher Microsoft.OSTCExtensions --version 1.4 --vm-name myvm --resource-group mygroup --protected-settings '{"username":"user1", "ssh_key":"ssh_rsa ..."}'
"""

helps['vm access set-linux-user'] = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def get_vm_size_completion_list(prefix, action, parsed_args, **kwargs):#pylint:

register_cli_argument('vm extension', 'vm_extension_name', name_arg_type, completer=get_resource_name_completion_list('Microsoft.Compute/virtualMachines/extensions'))
register_cli_argument('vm extension', 'vm_name', arg_type=existing_vm_name, options_list=('--vm-name',))
register_cli_argument('vm extension', 'auto_upgrade_minor_version', action='store_true')
register_cli_argument('vm extension', 'no_auto_upgrade', action='store_true')

register_cli_argument('vm extension image', 'image_location', options_list=('--location', '-l'))
register_cli_argument('vm extension image', 'publisher_name', options_list=('--publisher',))
Expand All @@ -109,7 +109,7 @@ def get_vm_size_completion_list(prefix, action, parsed_args, **kwargs):#pylint:

register_cli_argument('vmss extension', 'extension_name', name_arg_type, id_part='name', help='Name of extension')
register_cli_argument('vmss extension', 'vmss_name', help='Scale set name')
register_cli_argument('vmss extension', 'auto_upgrade_minor_version', action='store_true')
register_cli_argument('vmss extension', 'no_auto_upgrade', action='store_true')

register_cli_argument('vmss extension image', 'publisher_name', options_list=('--publisher',), help='Image publisher name')
register_cli_argument('vmss extension image', 'type', options_list=('--name', '-n'), help='Extension name')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,16 +503,17 @@ def list_extensions(resource_group_name, vm_name):
def set_extension(
resource_group_name, vm_name, vm_extension_name, publisher,
version=None, settings=None,
protected_settings=None, auto_upgrade_minor_version=False):
protected_settings=None, no_auto_upgrade=False):
'''create/update extensions for a VM in a resource group. You can use
'extension image list' to get extension details
:param vm_extension_name: the name of the extension
:param publisher: the name of extension publisher
:param version: the version of extension.
:param settings: public settings or a file path with such contents
:param protected_settings: protected settings or a file path with such contents
:param auto_upgrade_minor_version: pick the highest minor version for the specified version
number, and auto update to the latest build/revision number on any VM updates in future.
:param no_auto_upgrade: by doing this, extension system will not pick the highest minor version
for the specified version number, and will not auto update to the latest build/revision number
on any VM updates in future.
'''
vm = _vm_get(resource_group_name, vm_name)
client = _compute_client_factory()
Expand Down Expand Up @@ -541,22 +542,24 @@ def set_extension(
protected_settings=protected_settings,
type_handler_version=version,
settings=settings,
auto_upgrade_minor_version=auto_upgrade_minor_version)
auto_upgrade_minor_version=(not no_auto_upgrade))
return client.virtual_machine_extensions.create_or_update(
resource_group_name, vm_name, vm_extension_name, ext)

def set_vmss_extension(
resource_group_name, vmss_name, extension_name, publisher,
version=None, settings=None,
protected_settings=None, auto_upgrade_minor_version=False):
protected_settings=None, no_auto_upgrade=False):
'''create/update extensions for a VMSS in a resource group. You can use
'extension image list' to get extension details
:param vm_extension_name: the name of the extension
:param publisher: the name of extension publisher
:param version: the version of extension.
:param settings: public settings or a file path with such contents
:param protected_settings: protected settings or a file path with such contents
:param auto_upgrade_minor_version: auto upgrade to the newer version if available
:param no_auto_upgrade: by doing this, extension system will not pick the highest minor version
for the specified version number, and will not auto update to the latest build/revision number
on any scale set updates in future.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be reworded. "Set to disable the default extension system behavior which will automatically upgrade to the highest minor version number for the specified version."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us keep the wording, as it has been reviewed by VM linux team; also, it is not a default extension system behavior, rather just our command's default value. FYI, the behavior associated is complex that once you turn on the flag, and later when you update anything on VM, the extension will be updated as well.

'''
client = _compute_client_factory()
vmss = client.virtual_machine_scale_sets.get(resource_group_name,
Expand Down Expand Up @@ -586,7 +589,7 @@ def set_vmss_extension(
protected_settings=protected_settings,
type_handler_version=version,
settings=settings,
auto_upgrade_minor_version=auto_upgrade_minor_version)
auto_upgrade_minor_version=(not no_auto_upgrade))

if not vmss.virtual_machine_profile.extension_profile:
vmss.virtual_machine_profile.extension_profile = VirtualMachineScaleSetExtensionProfile([])
Expand Down
Loading