@@ -4562,19 +4562,34 @@ def restart_vmss(cmd, resource_group_name, vm_scale_set_name, instance_ids=None,
45624562
45634563# pylint: disable=inconsistent-return-statements
45644564def scale_vmss (cmd , resource_group_name , vm_scale_set_name , new_capacity , no_wait = False ):
4565- VirtualMachineScaleSet = cmd .get_models ('VirtualMachineScaleSet' )
4566- client = _compute_client_factory (cmd .cli_ctx )
4567- vmss = client .virtual_machine_scale_sets .get (resource_group_name , vm_scale_set_name )
4568- # pylint: disable=no-member
4569- if vmss .sku .capacity == new_capacity :
4565+ from .operations .vmss import VMSSCreate , VMSSShow
4566+ vmss = VMSSShow (cli_ctx = cmd .cli_ctx )(command_args = {
4567+ 'resource_group' : resource_group_name ,
4568+ 'vm_scale_set_name' : vm_scale_set_name
4569+ })
4570+ if vmss .get ('sku' , {}).get ('capacity' ) == new_capacity :
45704571 return
45714572
4572- vmss .sku .capacity = new_capacity
4573- vmss_new = VirtualMachineScaleSet (location = vmss .location , sku = vmss .sku )
4574- if vmss .extended_location is not None :
4575- vmss_new .extended_location = vmss .extended_location
4576- return sdk_no_wait (no_wait , client .virtual_machine_scale_sets .begin_create_or_update ,
4577- resource_group_name , vm_scale_set_name , vmss_new )
4573+ vmss_new = {
4574+ 'resource_group' : resource_group_name ,
4575+ 'vm_scale_set_name' : vm_scale_set_name ,
4576+ 'no_wait' : no_wait
4577+ }
4578+
4579+ if vmss .get ('extended_location' ):
4580+ vmss_new ['extended_location' ] = vmss ['extendedLocation' ]
4581+
4582+ if vmss .get ('location' ):
4583+ vmss_new ['location' ] = vmss ['location' ]
4584+
4585+ if vmss .get ('sku' ):
4586+ vmss_new ['sku' ] = vmss ['sku' ]
4587+ else :
4588+ vmss_new ['sku' ] = {}
4589+
4590+ vmss_new ['sku' ]['capacity' ] = new_capacity
4591+
4592+ return VMSSCreate (cli_ctx = cmd .cli_ctx )(command_args = vmss_new )
45784593
45794594
45804595def stop_vmss (cmd , resource_group_name , vm_scale_set_name , instance_ids = None , no_wait = False , skip_shutdown = False ):
0 commit comments