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
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/vm/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ 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)
g.custom_command('deallocate', 'deallocate_vmss', supports_no_wait=True)

with self.command_group('vmss', compute_vmss_sdk, operation_group='virtual_machine_scale_sets') as g:
Expand All @@ -415,7 +416,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
25 changes: 14 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 @@ -4516,19 +4516,22 @@ 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 +4519 to +4525
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['resource_group'] = resource_group_name
vmss['vm_scale_set_name'] = vm_scale_set_name
vmss['sku']['capacity'] = new_capacity
vmss['no_wait'] = no_wait

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


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