Skip to content

Commit 8c389b9

Browse files
committed
Create az functionapp flex-migration commands to migrate CV1 apps to Flex Consumption
1 parent c8ef40c commit 8c389b9

5 files changed

Lines changed: 1063 additions & 30 deletions

File tree

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,37 @@
982982
short-summary: List available built-in stacks which can be used for function apps on the Flex Consumption plan.
983983
"""
984984

985+
helps['functionapp flex-migration'] = """
986+
type: group
987+
short-summary: Manage migration of Linux Consumption function apps to the Flex Consumption plan.
988+
"""
989+
990+
helps['functionapp flex-migration start'] = """
991+
type: command
992+
short-summary: Create a Flex Consumption app with the same settings as the provided Linux Consumption function app.
993+
examples:
994+
- name: Migrate a Linux Consumption function app to the Flex Consumption plan.
995+
text: >
996+
az functionapp flex-migration start --source-name MyLinuxConsumptionApp --source-resource-group MyLinuxConsumptionResourceGroup --name MyFunctionApp --resource-group MyResourceGroup --storage-account MyStorageAccount
997+
998+
- name: Migrate a Linux Consumption function app to the Flex Consumption plan without configuring managed identity configurations.
999+
text: >
1000+
az functionapp flex-migration start --source-name MyLinuxConsumptionApp --source-resource-group MyLinuxConsumptionResourceGroup --name MyFunctionApp --resource-group MyResourceGroup --storage-account MyStorageAccount --skip-managed-identities
1001+
"""
1002+
1003+
helps['functionapp flex-migration list'] = """
1004+
type: command
1005+
short-summary: List all Linux Consumption function apps that are eligible for migration to the Flex Consumption plan.
1006+
examples:
1007+
- name: List all Linux Consumption function apps that are eligible for migration to the Flex Consumption plan.
1008+
text: >
1009+
az functionapp flex-migration list
1010+
1011+
- name: List all Linux Consumption function apps that are eligible for migration to the Flex Consumption plan, ignoring if they have slots configured. Please note that slots are not supported in the Flex Consumption plan.
1012+
text: >
1013+
az functionapp flex-migration list --ignore-slots
1014+
"""
1015+
9851016
helps['functionapp plan'] = """
9861017
type: group
9871018
short-summary: Manage App Service Plans for an Azure Function

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,25 @@ def load_arguments(self, _):
238238
help='Include the runtime details of the regions.', is_preview=True)
239239
c.argument('runtime', help="limit the output to just the specified runtime", is_preview=True)
240240

241+
with self.argument_context('functionapp flex-migration list') as c:
242+
c.argument('ignore_slots', arg_type=get_three_state_flag(return_label=True),
243+
help="Skip checking for slots for the existing function app. Please note that Flex Consumption does not support slots, so this should only be used if you do not intend to use slots.")
244+
245+
with self.argument_context('functionapp flex-migration start') as c:
246+
c.argument('source_resource_group', help='The resource group of the source function app to migrate from.')
247+
c.argument('source_name', help='The name of the source function app to migrate from.')
248+
c.argument('resource_group', help='The resource group of the target function app to migrate to.')
249+
c.argument('name', help='The name of the target function app to migrate to.')
250+
c.argument('storage_account', help='The storage account to use for the target function app.')
251+
c.argument('maximum_instance_count', type=int, help="The maximum number of instances.")
252+
c.argument('skip_managed_identities', options_list=['--skip-managed-identities', '--smi'], arg_type=get_three_state_flag(return_label=True), help="Skip migrating managed identities.")
253+
c.argument('skip_access_restrictions', options_list=['--skip-access-restrictions', '--sar'], arg_type=get_three_state_flag(return_label=True), help="Skip migrating access restrictions.")
254+
c.argument('skip_storage_mount', options_list=['--skip-storage-mount', '--ssm'], arg_type=get_three_state_flag(return_label=True), help="Skip migrating storage mounts.")
255+
c.argument('skip_hostnames', options_list=['--skip-hostnames', '--sh'], arg_type=get_three_state_flag(return_label=True), help="Skip migrating hostnames.")
256+
c.argument('skip_cors', options_list=['--skip-cors', '--sc'], arg_type=get_three_state_flag(return_label=True), help="Skip migrating CORS settings.")
257+
c.argument('ignore_slots', arg_type=get_three_state_flag(return_label=True),
258+
help="Skip checking for slots for the existing function app. Please note that Flex Consumption does not support slots, so this should only be used if you do not intend to use slots.")
259+
241260
with self.argument_context('webapp deleted list') as c:
242261
c.argument('name', arg_type=webapp_name_arg_type, id_part=None)
243262
c.argument('slot', options_list=['--slot', '-s'], help='Name of the deleted web app slot.')

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,10 @@ def load_command_table(self, _):
345345
custom_func_name='update_functionapp', getter_type=appservice_custom, setter_type=appservice_custom, command_type=webapp_sdk,
346346
validator=validate_functionapp_on_containerapp_update)
347347

348+
with self.command_group('functionapp flex-migration') as g:
349+
g.custom_command('start', 'migrate_consumption_to_flex', exception_handler=ex_handler_factory())
350+
g.custom_command('list', 'list_flex_migration_candidates', exception_handler=ex_handler_factory())
351+
348352
with self.command_group('functionapp deployment config') as g:
349353
g.custom_command('set', 'update_deployment_configs', exception_handler=ex_handler_factory(), validator=validate_is_flex_functionapp)
350354
g.custom_show_command('show', 'get_deployment_configs', exception_handler=ex_handler_factory(), validator=validate_is_flex_functionapp)

0 commit comments

Comments
 (0)