Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/azure-cli/azure/cli/command_modules/vm/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ def load_command_table(self, _):
g.custom_command('identity remove', 'remove_vmss_identity', validator=process_remove_identity_namespace, is_preview=True)
g.custom_show_command('identity show', 'show_vmss_identity')

g.custom_command('scale', 'scale_vmss', supports_no_wait=True)

with self.command_group('vmss', compute_vmss_sdk, operation_group='virtual_machine_scale_sets') as g:
g.custom_command('application set', 'set_vmss_applications', validator=process_set_applications_namespace, min_api='2021-07-01')
g.custom_command('application list', 'list_vmss_applications', min_api='2021-07-01')
Expand All @@ -412,7 +414,6 @@ def load_command_table(self, _):
g.custom_command('list-instances', 'get_instances_list')
g.custom_command('reimage', 'reimage_vmss', supports_no_wait=True, min_api='2017-03-30')
g.custom_command('restart', 'restart_vmss', supports_no_wait=True)
g.custom_command('scale', 'scale_vmss', supports_no_wait=True)
g.custom_show_command('show', 'get_vmss', table_transformer=get_vmss_table_output_transformer(self, False))
g.custom_command('stop', 'stop_vmss', supports_no_wait=True, validator=process_vm_vmss_stop)
g.generic_update_command('update', getter_name='get_vmss_modified_by_aaz', setter_name='update_vmss', supports_no_wait=True, command_type=compute_custom, validator=validate_vmss_update_namespace)
Expand Down
23 changes: 12 additions & 11 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4493,19 +4493,20 @@ def restart_vmss(cmd, resource_group_name, vm_scale_set_name, instance_ids=None,

# pylint: disable=inconsistent-return-statements
def scale_vmss(cmd, resource_group_name, vm_scale_set_name, new_capacity, no_wait=False):
VirtualMachineScaleSet = cmd.get_models('VirtualMachineScaleSet')
client = _compute_client_factory(cmd.cli_ctx)
vmss = client.virtual_machine_scale_sets.get(resource_group_name, vm_scale_set_name)
# pylint: disable=no-member
if vmss.sku.capacity == new_capacity:
from .operations.vmss import VMSSCreate, VMSSShow, convert_show_result_to_snake_case
vmss = VMSSShow(cli_ctx=cmd.cli_ctx)(command_args={
'resource_group': resource_group_name,
'vm_scale_set_name': vm_scale_set_name
})
vmss = convert_show_result_to_snake_case(vmss)

Comment on lines +4496 to +4502
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

VMSSCreate requires resource_group and vm_scale_set_name arguments (see aaz latest vmss Create args schema). The dict produced by convert_show_result_to_snake_case(vmss) doesn’t include these keys, so this call will fail with missing required arguments. Please add resource_group=resource_group_name and vm_scale_set_name=vm_scale_set_name to the command_args passed to VMSSCreate (either by setting them on vmss or by constructing a new args dict).

Copilot uses AI. Check for mistakes.
if vmss.get('sku', {}).get('capacity') == new_capacity:
return

vmss.sku.capacity = new_capacity
vmss_new = VirtualMachineScaleSet(location=vmss.location, sku=vmss.sku)
if vmss.extended_location is not None:
vmss_new.extended_location = vmss.extended_location
return sdk_no_wait(no_wait, client.virtual_machine_scale_sets.begin_create_or_update,
resource_group_name, vm_scale_set_name, vmss_new)
vmss['sku']['capacity'] = new_capacity
vmss['no_wait'] = no_wait

VMSSCreate(cli_ctx=cmd.cli_ctx)(command_args=vmss)
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

scale_vmss doesn’t return the result/poller from VMSSCreate(...). This changes the command behavior (no output) and will break existing tests that assert on vmss scale output (e.g., extendedLocation). Return the result of VMSSCreate(...) (and/or the LRO poller when --no-wait is used), consistent with update_vmss which returns VMSSCreate(...).

Suggested change
VMSSCreate(cli_ctx=cmd.cli_ctx)(command_args=vmss)
return VMSSCreate(cli_ctx=cmd.cli_ctx)(command_args=vmss)

Copilot uses AI. Check for mistakes.


def stop_vmss(cmd, resource_group_name, vm_scale_set_name, instance_ids=None, no_wait=False, skip_shutdown=False):
Expand Down
Loading