Skip to content

Commit

Permalink
Use raw requests instead of SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
kamperiadis committed Feb 8, 2024
1 parent ed200a8 commit 8cd84f1
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 153 deletions.
13 changes: 13 additions & 0 deletions src/azure-cli/azure/cli/command_modules/appservice/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ def validate_functionapp_on_flex_plan(cmd, namespace):
'on the Flex Consumption plan.')


def validate_is_flex_functionapp(cmd, namespace):
resource_group_name = namespace.resource_group_name
name = namespace.name
functionapp = _generic_site_operation(cmd.cli_ctx, resource_group_name, name, 'get')
parsed_plan_id = parse_resource_id(functionapp.server_farm_id)
client = web_client_factory(cmd.cli_ctx)
plan_info = client.app_service_plans.get(parsed_plan_id['resource_group'], parsed_plan_id['name'])
if plan_info is None:
raise ResourceNotFoundError('Could not determine the current plan of the functionapp')
if plan_info.sku.tier.lower() != 'flexconsumption':
raise ValidationError('This command is only valid for Azure Functions on the FlexConsumption plan.')


def validate_app_exists(cmd, namespace):
app = namespace.name
resource_group_name = namespace.resource_group_name
Expand Down
10 changes: 5 additions & 5 deletions src/azure-cli/azure/cli/command_modules/appservice/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
validate_functionapp_on_containerapp_site_config_show,
validate_functionapp_on_containerapp_container_settings_delete,
validate_functionapp_on_containerapp_update, validate_functionapp_on_flex_plan,
validate_functionapp)
validate_functionapp, validate_is_flex_functionapp)


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

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

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

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

0 comments on commit 8cd84f1

Please sign in to comment.