@@ -2498,10 +2498,9 @@ def aks_agentpool_scale(cmd, # pylint: disable=unused-argument
24982498 instance .count = new_node_count # pylint: disable=no-member
24992499
25002500 # By default scale via the PUT agent pool API (begin_create_or_update).
2501- # When --use-patch-api is set, scale a VMSS node pool via the preview PATCH agent
2501+ # When --use-patch-api is set, scale the node pool via the preview PATCH agent
25022502 # pool API, which scales to the target count without a full reconciliation.
2503- # VirtualMachines node pools are not supported yet and keep using the PUT API.
2504- if use_patch_api and instance .type_properties_type == CONST_VIRTUAL_MACHINE_SCALE_SETS :
2503+ if use_patch_api :
25052504 return _aks_agentpool_scale_patch (
25062505 cmd ,
25072506 client ,
@@ -2531,10 +2530,11 @@ def _aks_agentpool_scale_patch(cmd,
25312530 instance ,
25322531 headers = None ,
25332532 no_wait = False ):
2534- """Scale a VMSS agent pool via the dedicated PATCH agent pool API.
2533+ """Scale an agent pool via the dedicated PATCH agent pool API.
25352534
2536- Sends only the already-updated target count on ``instance`` so the pool scales
2537- without triggering a full agent pool reconciliation.
2535+ Sends only the already-updated target count (VMSS) or manual scale profiles
2536+ (VirtualMachines) on ``instance`` so the pool scales without triggering a full
2537+ agent pool reconciliation.
25382538 """
25392539 AgentPoolUpdate = cmd .get_models (
25402540 "AgentPoolUpdate" ,
@@ -2547,7 +2547,35 @@ def _aks_agentpool_scale_patch(cmd,
25472547 operation_group = "agent_pools" ,
25482548 )
25492549
2550- parameters = AgentPoolUpdate (properties = AgentPoolUpdateProperties (count = instance .count ))
2550+ if instance .type_properties_type == CONST_VIRTUAL_MACHINES :
2551+ AgentPoolUpdateVirtualMachinesProfile = cmd .get_models (
2552+ "AgentPoolUpdateVirtualMachinesProfile" ,
2553+ resource_type = CUSTOM_MGMT_AKS_PREVIEW ,
2554+ operation_group = "agent_pools" ,
2555+ )
2556+ AgentPoolUpdateScaleProfile = cmd .get_models (
2557+ "AgentPoolUpdateScaleProfile" ,
2558+ resource_type = CUSTOM_MGMT_AKS_PREVIEW ,
2559+ operation_group = "agent_pools" ,
2560+ )
2561+ AgentPoolUpdateManualScaleProfile = cmd .get_models (
2562+ "AgentPoolUpdateManualScaleProfile" ,
2563+ resource_type = CUSTOM_MGMT_AKS_PREVIEW ,
2564+ operation_group = "agent_pools" ,
2565+ )
2566+ manual = [
2567+ AgentPoolUpdateManualScaleProfile (size = m .size , count = m .count )
2568+ for m in instance .virtual_machines_profile .scale .manual
2569+ ]
2570+ properties = AgentPoolUpdateProperties (
2571+ virtual_machines_profile = AgentPoolUpdateVirtualMachinesProfile (
2572+ scale = AgentPoolUpdateScaleProfile (manual = manual )
2573+ )
2574+ )
2575+ else :
2576+ properties = AgentPoolUpdateProperties (count = instance .count )
2577+
2578+ parameters = AgentPoolUpdate (properties = properties )
25512579 return sdk_no_wait (
25522580 no_wait ,
25532581 client .begin_update ,
@@ -3097,6 +3125,7 @@ def aks_agentpool_manual_scale_add(cmd,
30973125 nodepool_name ,
30983126 vm_sizes ,
30993127 node_count ,
3128+ use_patch_api = False ,
31003129 no_wait = False ):
31013130 instance = client .get (resource_group_name , cluster_name , nodepool_name )
31023131 if instance .type_properties_type != CONST_VIRTUAL_MACHINES :
@@ -3112,6 +3141,18 @@ def aks_agentpool_manual_scale_add(cmd,
31123141 new_manual_scale_profile = ManualScaleProfile (size = sizes [0 ], count = int (node_count ))
31133142 instance .virtual_machines_profile .scale .manual .append (new_manual_scale_profile )
31143143
3144+ # When --use-patch-api is set, add the manual scale profile via the preview
3145+ # PATCH agent pool API instead of the default PUT API.
3146+ if use_patch_api :
3147+ return _aks_agentpool_scale_patch (
3148+ cmd ,
3149+ client ,
3150+ resource_group_name ,
3151+ cluster_name ,
3152+ nodepool_name ,
3153+ instance ,
3154+ no_wait = no_wait ,
3155+ )
31153156 return sdk_no_wait (
31163157 no_wait ,
31173158 client .begin_create_or_update ,
@@ -3122,14 +3163,15 @@ def aks_agentpool_manual_scale_add(cmd,
31223163 )
31233164
31243165
3125- def aks_agentpool_manual_scale_update (cmd , # pylint: disable=unused-argument
3166+ def aks_agentpool_manual_scale_update (cmd ,
31263167 client ,
31273168 resource_group_name ,
31283169 cluster_name ,
31293170 nodepool_name ,
31303171 current_vm_sizes ,
31313172 vm_sizes = None ,
31323173 node_count = None ,
3174+ use_patch_api = False ,
31333175 no_wait = False ):
31343176 if vm_sizes is None and node_count is None :
31353177 raise RequiredArgumentMissingError ("specify --vm-sizes or --node-count or both." )
@@ -3160,6 +3202,18 @@ def aks_agentpool_manual_scale_update(cmd, # pylint: disable=unused-argument
31603202 f"Manual with size { current_vm_sizes [0 ]} doesn't exist in node pool { nodepool_name } "
31613203 )
31623204
3205+ # When --use-patch-api is set, update the manual scale profiles via the preview
3206+ # PATCH agent pool API instead of the default PUT API.
3207+ if use_patch_api :
3208+ return _aks_agentpool_scale_patch (
3209+ cmd ,
3210+ client ,
3211+ resource_group_name ,
3212+ cluster_name ,
3213+ nodepool_name ,
3214+ instance ,
3215+ no_wait = no_wait ,
3216+ )
31633217 return sdk_no_wait (
31643218 no_wait ,
31653219 client .begin_create_or_update ,
@@ -3170,12 +3224,13 @@ def aks_agentpool_manual_scale_update(cmd, # pylint: disable=unused-argument
31703224 )
31713225
31723226
3173- def aks_agentpool_manual_scale_delete (cmd , # pylint: disable=unused-argument
3227+ def aks_agentpool_manual_scale_delete (cmd ,
31743228 client ,
31753229 resource_group_name ,
31763230 cluster_name ,
31773231 nodepool_name ,
31783232 current_vm_sizes ,
3233+ use_patch_api = False ,
31793234 no_wait = False ):
31803235 instance = client .get (resource_group_name , cluster_name , nodepool_name )
31813236 if instance .type_properties_type != CONST_VIRTUAL_MACHINES :
@@ -3196,6 +3251,18 @@ def aks_agentpool_manual_scale_delete(cmd, # pylint: disable=unused-argument
31963251 f"Manual with size { current_vm_sizes [0 ]} doesn't exist in node pool { nodepool_name } "
31973252 )
31983253
3254+ # When --use-patch-api is set, delete the manual scale profile via the preview
3255+ # PATCH agent pool API instead of the default PUT API.
3256+ if use_patch_api :
3257+ return _aks_agentpool_scale_patch (
3258+ cmd ,
3259+ client ,
3260+ resource_group_name ,
3261+ cluster_name ,
3262+ nodepool_name ,
3263+ instance ,
3264+ no_wait = no_wait ,
3265+ )
31993266 return sdk_no_wait (
32003267 no_wait ,
32013268 client .begin_create_or_update ,
0 commit comments