Skip to content

Commit 8cd84f1

Browse files
committed
Use raw requests instead of SDK
1 parent ed200a8 commit 8cd84f1

File tree

4 files changed

+195
-153
lines changed

4 files changed

+195
-153
lines changed

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

+13
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,19 @@ def validate_functionapp_on_flex_plan(cmd, namespace):
174174
'on the Flex Consumption plan.')
175175

176176

177+
def validate_is_flex_functionapp(cmd, namespace):
178+
resource_group_name = namespace.resource_group_name
179+
name = namespace.name
180+
functionapp = _generic_site_operation(cmd.cli_ctx, resource_group_name, name, 'get')
181+
parsed_plan_id = parse_resource_id(functionapp.server_farm_id)
182+
client = web_client_factory(cmd.cli_ctx)
183+
plan_info = client.app_service_plans.get(parsed_plan_id['resource_group'], parsed_plan_id['name'])
184+
if plan_info is None:
185+
raise ResourceNotFoundError('Could not determine the current plan of the functionapp')
186+
if plan_info.sku.tier.lower() != 'flexconsumption':
187+
raise ValidationError('This command is only valid for Azure Functions on the FlexConsumption plan.')
188+
189+
177190
def validate_app_exists(cmd, namespace):
178191
app = namespace.name
179192
resource_group_name = namespace.resource_group_name

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
validate_functionapp_on_containerapp_site_config_show,
1818
validate_functionapp_on_containerapp_container_settings_delete,
1919
validate_functionapp_on_containerapp_update, validate_functionapp_on_flex_plan,
20-
validate_functionapp)
20+
validate_functionapp, validate_is_flex_functionapp)
2121

2222

2323
def output_slots_in_table(slots):
@@ -344,12 +344,12 @@ def load_command_table(self, _):
344344
g.custom_command('delete', 'delete_app_settings', exception_handler=ex_handler_factory())
345345

346346
with self.command_group('functionapp scale config') as g:
347-
g.custom_command('show', 'get_scale_config', exception_handler=ex_handler_factory())
348-
g.custom_command('set', 'update_scale_config', exception_handler=ex_handler_factory())
347+
g.custom_command('show', 'get_scale_config', exception_handler=ex_handler_factory(), validator=validate_is_flex_functionapp)
348+
g.custom_command('set', 'update_scale_config', exception_handler=ex_handler_factory(), validator=validate_is_flex_functionapp)
349349

350350
with self.command_group('functionapp scale config always-ready') as g:
351-
g.custom_command('delete', 'delete_always_ready_settings', exception_handler=ex_handler_factory())
352-
g.custom_command('set', 'update_always_ready_settings', exception_handler=ex_handler_factory())
351+
g.custom_command('delete', 'delete_always_ready_settings', exception_handler=ex_handler_factory(), validator=validate_is_flex_functionapp)
352+
g.custom_command('set', 'update_always_ready_settings', exception_handler=ex_handler_factory(), validator=validate_is_flex_functionapp)
353353

354354
with self.command_group('functionapp config hostname') as g:
355355
g.custom_command('add', 'add_hostname', exception_handler=ex_handler_factory())

0 commit comments

Comments
 (0)