Skip to content

Commit b4a1f2c

Browse files
committed
Add async param to update and create
1 parent 617ddcf commit b4a1f2c

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/azure-cli/azure/cli/command_modules/appservice/_params.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,15 @@ def load_arguments(self, _):
126126
'the App Service plan that hosts it.')
127127
c.argument('zone_redundant', options_list=['--zone-redundant', '-z'], help='Enable zone redundancy for high availability. Minimum instance count is 2.')
128128
c.argument('tags', arg_type=tags_type)
129+
c.argument('async_scaling_enabled', action='store_true', help='Enable async scaling for the app service plan. This will create an async operation if there are insufficient workers to scale synchronously.')
129130

130131
with self.argument_context('appservice plan update') as c:
131132
c.argument('sku', arg_type=sku_arg_type)
132133
c.argument('elastic_scale', arg_type=get_three_state_flag(), is_preview=True, help='Enable or disable automatic scaling. Set to "true" to enable elastic scale for this plan, or "false" to disable elastic scale for this plan. The SKU must be a Premium V2 SKU (P1V2, P2V2, P3V2) or a Premium V3 SKU (P1V3, P2V3, P3V3)')
133134
c.argument('max_elastic_worker_count', options_list=['--max-elastic-worker-count', '-m'], type=int, is_preview=True, help='Maximum number of instances that the plan can scale out to. The plan must be an elastic scale plan.')
134135
c.argument('number_of_workers', type=int, help='Number of workers to be allocated.')
135136
c.ignore('allow_pending_state')
137+
c.argument('async_scaling_enabled', arg_type=get_three_state_flag(), help='Enable async scaling for the app service plan. This will create an async operation if there are insufficient workers to scale synchronously.')
136138

137139
with self.argument_context('appservice plan delete') as c:
138140
c.argument('name', arg_type=name_arg_type, help='The name of the app service plan',

src/azure-cli/azure/cli/command_modules/appservice/custom.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3965,7 +3965,7 @@ def _enable_zone_redundant(plan_def, sku_def, number_of_workers):
39653965

39663966
def create_app_service_plan(cmd, resource_group_name, name, is_linux, hyper_v, per_site_scaling=False,
39673967
app_service_environment=None, sku='B1', number_of_workers=None, location=None,
3968-
tags=None, no_wait=False, zone_redundant=False):
3968+
tags=None, no_wait=False, zone_redundant=False, async_scaling_enabled=None):
39693969
HostingEnvironmentProfile, SkuDescription, AppServicePlan = cmd.get_models(
39703970
'HostingEnvironmentProfile', 'SkuDescription', 'AppServicePlan')
39713971

@@ -4004,7 +4004,8 @@ def create_app_service_plan(cmd, resource_group_name, name, is_linux, hyper_v, p
40044004
sku_def = SkuDescription(tier=get_sku_tier(sku), name=_normalize_sku(sku), capacity=number_of_workers)
40054005
plan_def = AppServicePlan(location=location, tags=tags, sku=sku_def,
40064006
reserved=(is_linux or None), hyper_v=(hyper_v or None),
4007-
per_site_scaling=per_site_scaling, hosting_environment_profile=ase_def)
4007+
per_site_scaling=per_site_scaling, hosting_environment_profile=ase_def,
4008+
async_scaling_enabled=async_scaling_enabled)
40084009

40094010
if sku.upper() in ['WS1', 'WS2', 'WS3']:
40104011
existing_plan = get_resource_if_exists(client.app_service_plans,
@@ -4022,11 +4023,17 @@ def create_app_service_plan(cmd, resource_group_name, name, is_linux, hyper_v, p
40224023

40234024

40244025
def update_app_service_plan(cmd, instance, sku=None, number_of_workers=None, elastic_scale=None,
4025-
max_elastic_worker_count=None):
4026-
if number_of_workers is None and sku is None and elastic_scale is None and max_elastic_worker_count is None:
4026+
max_elastic_worker_count=None, async_scaling_enabled=None):
4027+
if (number_of_workers is None and sku is None and
4028+
elastic_scale is None and max_elastic_worker_count is None and
4029+
async_scaling_enabled is None):
40274030
safe_params = cmd.cli_ctx.data['safe_params']
40284031
if '--set' not in safe_params:
4029-
args = ["--number-of-workers", "--sku", "--elastic-scale", "--max-elastic-worker-count"]
4032+
args = ["--number-of-workers",
4033+
"--sku",
4034+
"--elastic-scale",
4035+
"--max-elastic-worker-count",
4036+
"--async-scaling-enabled"]
40304037
logger.warning('Nothing to update. Set one of the following parameters to make an update: %s', str(args))
40314038
sku_def = instance.sku
40324039
if sku is not None:
@@ -4062,10 +4069,12 @@ def update_app_service_plan(cmd, instance, sku=None, number_of_workers=None, ela
40624069
use_additional_properties(instance)
40634070
instance.additional_properties["properties"]["maximumElasticWorkerCount"] = max_elastic_worker_count
40644071

4072+
if async_scaling_enabled is not None:
4073+
instance.async_scaling_enabled = async_scaling_enabled
4074+
40654075
instance.sku = sku_def
40664076
return instance
40674077

4068-
40694078
def show_plan(cmd, resource_group_name, name):
40704079
from azure.cli.core.commands.client_factory import get_subscription_id
40714080
client = web_client_factory(cmd.cli_ctx)

0 commit comments

Comments
 (0)