Skip to content

Commit 7b64542

Browse files
authored
[App Service] az webapp update/az appservice plan update: Add new parameter --elastic-web-app-scale-limit and scaling parameter options (#28297)
1 parent 00e55b5 commit 7b64542

7 files changed

+2589
-477
lines changed

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def load_arguments(self, _):
133133
with self.argument_context('appservice plan update') as c:
134134
c.argument('sku', arg_type=sku_arg_type)
135135
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)')
136-
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.')
136+
c.argument('max_elastic_worker_count', options_list=['--max-elastic-worker-count', '--max-app-service-plan-instance-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.')
137137
c.argument('number_of_workers', type=int, help='Number of workers to be allocated.')
138138
c.ignore('allow_pending_state')
139139

@@ -210,8 +210,9 @@ def load_arguments(self, _):
210210
arg_type=get_three_state_flag(return_label=True), deprecate_info=c.deprecate(expiration='3.0.0'))
211211
c.argument('skip_dns_registration', help="If true web app hostname is not registered with DNS on creation",
212212
arg_type=get_three_state_flag(return_label=True), deprecate_info=c.deprecate(expiration='3.0.0'))
213-
c.argument('minimum_elastic_instance_count', options_list=["--minimum-elastic-instance-count", "-i"], type=int, is_preview=True, help="Minimum number of instances. App must be in an elastic scale App Service Plan.")
214-
c.argument('prewarmed_instance_count', options_list=["--prewarmed-instance-count", "-w"], type=int, is_preview=True, help="Number of preWarmed instances. App must be in an elastic scale App Service Plan.")
213+
c.argument('minimum_elastic_instance_count', options_list=['--minimum-elastic-instance-count', '--min-web-app-instance-count', '-i'], type=int, is_preview=True, help="Minimum number of instances. App must be in an elastic scale App Service Plan.")
214+
c.argument('elastic_web_app_scale_limit', options_list=['--elastic-web-app-scale-limit', '--max-web-app-instance-count', '-x'], type=int, is_preview=True, help="Maximum number of instances. App must be in an elastic scale App Service Plan.")
215+
c.argument('prewarmed_instance_count', options_list=['--prewarmed-instance-count', '-w'], type=int, is_preview=True, help="Number of preWarmed instances. App must be in an elastic scale App Service Plan.")
215216
c.argument('basic_auth', help='Enable or disable basic auth.', arg_type=get_enum_type(BASIC_AUTH_TYPES))
216217

217218
with self.argument_context('webapp browse') as c:

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

+21-5
Original file line numberDiff line numberDiff line change
@@ -959,25 +959,33 @@ def set_webapp(cmd, resource_group_name, name, slot=None, skip_dns_registration=
959959

960960

961961
def update_webapp(cmd, instance, client_affinity_enabled=None, https_only=None, minimum_elastic_instance_count=None,
962-
prewarmed_instance_count=None):
962+
elastic_web_app_scale_limit=None, prewarmed_instance_count=None):
963963
if 'function' in instance.kind:
964964
raise ValidationError("please use 'az functionapp update' to update this function app")
965-
if minimum_elastic_instance_count or prewarmed_instance_count:
966-
args = ["--minimum-elastic-instance-count", "--prewarmed-instance-count"]
965+
if minimum_elastic_instance_count or prewarmed_instance_count or elastic_web_app_scale_limit:
966+
args = ["--minimum-elastic-instance-count", "--prewarmed-instance-count", "--elastic-web-app-scale-limit"]
967967
plan = get_app_service_plan_from_webapp(cmd, instance)
968968
sku = _normalize_sku(plan.sku.name)
969969
if get_sku_tier(sku) not in ["PREMIUMV2", "PREMIUMV3"]:
970970
raise ValidationError("{} are only supported for elastic premium V2/V3 SKUs".format(str(args)))
971971
if not plan.elastic_scale_enabled:
972972
raise ValidationError("Elastic scale is not enabled on the App Service Plan. Please update the plan ")
973+
if ((elastic_web_app_scale_limit or 0) < 0) or \
974+
((minimum_elastic_instance_count or 0) < 0) or \
975+
((prewarmed_instance_count or 0) < 0):
976+
raise ValidationError("Value cannot be less than 0 for {}.".format(str(args)))
973977
if (minimum_elastic_instance_count or 0) > plan.maximum_elastic_worker_count:
974978
raise ValidationError("--minimum-elastic-instance-count: Minimum elastic instance count is greater than "
975979
"the app service plan's maximum Elastic worker count. "
976-
"Please choose a lower count or update the plan's maximum ")
980+
"Please choose a lower count or update the plan's maximum.")
977981
if (prewarmed_instance_count or 0) > plan.maximum_elastic_worker_count:
978982
raise ValidationError("--prewarmed-instance-count: Prewarmed instance count is greater than "
979983
"the app service plan's maximum Elastic worker count. "
980-
"Please choose a lower count or update the plan's maximum ")
984+
"Please choose a lower count or update the plan's maximum.")
985+
if (elastic_web_app_scale_limit or 0) > plan.maximum_elastic_worker_count:
986+
raise ValidationError("--elastic-web-app-scale-limit: Elastic web app scale limit is greater than "
987+
"the app service plan's maximum Elastic worker count. "
988+
"Please choose a lower count or update the plan's maximum.")
981989

982990
if client_affinity_enabled is not None:
983991
instance.client_affinity_enabled = client_affinity_enabled == 'true'
@@ -994,6 +1002,14 @@ def update_webapp(cmd, instance, client_affinity_enabled=None, https_only=None,
9941002
if prewarmed_instance_count is not None:
9951003
instance.site_config.pre_warmed_instance_count = prewarmed_instance_count
9961004

1005+
if elastic_web_app_scale_limit is not None:
1006+
instance.site_config.elastic_web_app_scale_limit = elastic_web_app_scale_limit
1007+
minim = instance.site_config.minimum_elastic_instance_count
1008+
if minim and (elastic_web_app_scale_limit < minim):
1009+
raise ValidationError("--elastic-web-app-scale-limit: Elastic web app scale limit "
1010+
"cannot be less than minimum elastic instance count. "
1011+
"Please choose a higher count or update the minimum elastic instance count.")
1012+
9971013
return instance
9981014

9991015

0 commit comments

Comments
 (0)