[AppService] az functionapp flex-migration start: Add in-place CV1 to Flex Consumption upgrade support - #33863
Conversation
… to Flex upgrade Add in-place CV1 Linux Consumption -> Flex Consumption upgrade support to the existing 'az functionapp flex-migration start' command via a new '--in-place' flag. When set, the command upgrades the source app directly (same app, same name, same hostname) instead of creating a new side-by-side app. Changes: - custom.py: Add in_place branching + _upgrade_consumption_to_flex_in_place() - _params.py: Add --in-place/-i and deployment-storage/scale params - _help.py: Update group summary and add in-place example - tests: Add 7 mock unit tests + 4 live scenario tests Design: based on cv1-to-flex-upgrade-uber-design/14-azure-cli.md Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Thank you for your contribution Sreemoyee Sadhukhan (@Sreemoyee26)! We will review the pull request and get back to you soon. |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
appservice |
…eLimit) before Flex PUT The GET-mutate-PUT pattern carries CV1-specific siteConfig properties that the server rejects for Flex Consumption sites. Clear linux_fx_version and function_app_scale_limit before submitting the upgrade PUT request. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
The server-side SkuTransitionResolver reads siteEnvelope.Sku.Name (top-level),
not properties.sku. The SDK Site model serializes sku into properties, so we
serialize to dict and inject the top-level sku: {name: 'FlexConsumption'}
manually. This enables the CV1-to-Flex upgrade orchestrator to fire correctly.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
…er upgrade The site PUT's siteConfig.appSettings is ignored by the SkuTransitionResolver orchestrator during the CV1->Flex upgrade. The orchestrator preserves only the settings from /config/appsettings, discarding anything in the PUT body's siteConfig.appSettings. Move the DEPLOYMENT_STORAGE_CONNECTION_STRING setting to a separate update_application_settings call after the upgrade completes, merging it with existing settings rather than replacing them. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
Ensure the deployment storage connection setting is available to the server-side content migration step, and trim redundant comments in the in-place upgrade helper. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
az functionapp flex-migration start: Add in-place CV1 to Flex Consumption upgrade support
Extract target argument validation to reduce branch complexity and reuse the module-level validator import. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Adds an --in-place mode to az functionapp flex-migration start to upgrade an existing CV1 Linux Consumption function app directly to Flex Consumption (preserving app name/hostname), alongside new scale/deployment-storage parameters, updated help, and new live + mocked tests.
Changes:
- Add
--in-placeexecution branch with deployment storage + scale configuration support inmigrate_consumption_to_flex. - Extend CLI parameters/help text to describe in-place vs side-by-side migration and new deployment-storage/scale flags.
- Add scenario (live) and mocked tests covering in-place argument validation and basic migration behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/appservice/custom.py | Adds --in-place validation and an in-place upgrade implementation that configures deployment storage and Flex config on the existing site. |
| src/azure-cli/azure/cli/command_modules/appservice/_params.py | Adds --in-place and new scale/deployment-storage arguments for functionapp flex-migration start. |
| src/azure-cli/azure/cli/command_modules/appservice/_help.py | Updates help text and adds an in-place usage example. |
| src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_functionapp_commands.py | Adds live scenario coverage for in-place migration and CLI-level negative-path checks. |
| src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_functionapp_commands_thru_mock.py | Adds mocked/unit tests validating --in-place argument semantics and eligibility checks. |
Suppressed comments (1)
src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_functionapp_commands.py:1401
- Same as above: this negative-path
LiveScenarioTestshould useexpect_failure=True(the common pattern in this test file) instead ofassertRaises(SystemExit).
def test_functionapp_flex_migration_side_by_side_requires_target_args(self):
"""Side-by-side without --name/--resource-group should fail."""
with self.assertRaises(SystemExit):
self.cmd('functionapp flex-migration start --source-resource-group rg --source-name app')
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| deployment_storage_auth_config = {"type": deployment_storage_auth_type} | ||
|
|
||
| app_settings_to_add = [] | ||
| if deployment_storage_auth_type == 'UserAssignedIdentity': | ||
| deployment_storage_user_assigned_identity = _get_or_create_user_assigned_identity( | ||
| cmd, source_resource_group, source_name, deployment_storage_auth_value, source.location) | ||
| deployment_storage_auth_value = deployment_storage_user_assigned_identity.id | ||
| deployment_storage_auth_config["userAssignedIdentityResourceId"] = deployment_storage_auth_value | ||
| elif deployment_storage_auth_type == 'StorageAccountConnectionString': | ||
| deployment_storage_conn_string = _get_storage_connection_string(cmd.cli_ctx, deployment_storage) | ||
| conn_string_app_setting = deployment_storage_auth_value or 'DEPLOYMENT_STORAGE_CONNECTION_STRING' | ||
| app_settings_to_add.append({'name': conn_string_app_setting, 'value': deployment_storage_conn_string}) | ||
| deployment_storage_auth_value = conn_string_app_setting | ||
| deployment_storage_auth_config["storageAccountConnectionStringName"] = deployment_storage_auth_value | ||
|
|
| result = self.cmd( | ||
| 'functionapp flex-migration start --source-resource-group {} --source-name {} --in-place ' | ||
| '--deployment-storage-name {} --deployment-storage-container-name mycontainer' | ||
| .format(resource_group, src_name, storage_account) | ||
| ).get_output_in_json() |
| def test_functionapp_flex_migration_in_place_rejects_target_args(self): | ||
| """--in-place with --name should fail.""" | ||
| with self.assertRaises(SystemExit): | ||
| self.cmd('functionapp flex-migration start --source-resource-group rg --source-name app ' | ||
| '--in-place --name target-app --resource-group target-rg') | ||
|
|
| - name: Upgrade a Linux Consumption function app to Flex Consumption in place (same app, same name). | ||
| text: > | ||
| az functionapp flex-migration start --source-name MyLinuxConsumptionApp --source-resource-group MyResourceGroup --in-place |
🤖 PR Validation —⚠️ Review suggested
Summary
Add in-place CV1 Linux Consumption to Flex Consumption upgrade support through the new
--in-placeflag. The command upgrades the source app directly, preserving its name and hostname instead of creating a side-by-side app.The implementation also:
Related command
az functionapp flex-migration startDescription
When
--in-placeis specified, the command validates the source Linux Consumption app, builds its Flex Consumption configuration, configures deployment storage, and updates the existing site. Existing side-by-side migration behavior remains unchanged when--in-placeis omitted.Testing Guide
7 passedforTestFlexMigrationInPlaceMocked.130/130tests passed.HTTP 200).az functionapp flex-migration start --source-name cv1-flex-verify2-app --source-resource-group rg-cv1-flex-verify2 --in-placeFlexConsumption, stateRunning, Python 3.11 runtime, deployment storage, andDEPLOYMENT_STORAGE_CONNECTION_STRING.HTTP 200).