Fix: Prevent runtime downgrade when using --publish-settings-only on Flex Consumption#4761
Conversation
|
@copilot can you identify why PublishAppSettings updates the runtime to begin with? Can we decouple that logic from the updating the runtime? |
Good catch! I've decoupled the runtime update logic from Why it was coupled: For Flex apps, What changed (commit 419ded8):
This gives clearer separation— |
|
@copilot I have refactored the work here, please updare the PR description to reflect the latest changes |
Updated the PR description to reflect the latest refactoring changes. |
|
@copilot please address any feedback provided in this pull request |
|
@copilot rebase main |
Rebase completed successfully. The branch has been rebased onto the latest main (commit cfef95a). All 8 commits are now on top of main which includes 4 new commits:
The rebase had no conflicts. However, I cannot force-push the rebased branch due to authentication constraints. You'll need to manually force-push with: |
… apps Co-authored-by: liliankasem <2198905+liliankasem@users.noreply.github.com>
- Extract runtime update logic into separate UpdateFlexRuntimeFromLocalSettings method - PublishAppSettings now only handles app settings publishing - PublishLocalAppSettings conditionally calls runtime update based on PublishLocalSettingsOnly flag - Clearer separation of concerns between settings and runtime updates Co-authored-by: liliankasem <2198905+liliankasem@users.noreply.github.com>
- Extract Flex runtime settings from localAppSettings BEFORE calling PublishAppSettings - Fixes issue where runtime keys were removed before they could be read - Simplifies logic by handling extraction inline instead of separate method Co-authored-by: liliankasem <2198905+liliankasem@users.noreply.github.com>
Co-authored-by: liliankasem <2198905+liliankasem@users.noreply.github.com>
- Changed Console.WriteLine to ColoredConsole.WriteLine for target framework detection - Reduced nesting in ValidateFunctionAppPublish by using else if - Added unit tests for UpdateRuntimeConfigForFlex method covering: * Skipping update when no runtime version is detected * Skipping update when versions match * Updating runtime when versions differ with force flag Co-authored-by: liliankasem <2198905+liliankasem@users.noreply.github.com>
063203c to
db378ae
Compare
Issue describing the changes in this PR
When using
--publish-settings-onlywith Flex Consumption apps, the runtime stack is silently downgraded (e.g., .NET 9 isolated → .NET 8 isolated). The flag should only sync app settings without modifying runtime configuration.Root cause: Runtime update logic was coupled within
PublishAppSettings, causing runtime updates to occur even during settings-only operations. Additionally, the system was defaulting to .NET 8.0 instead of detecting the actual target framework from the project file.Changes:
PublishAppSettings- it now purely handles app settings_requiredNetFrameworkVersionnow defaults tonull)ValidateFunctionAppPublishto occur BEFORE code deployment for Flex appsUpdateRuntimeConfigForFlexwith intelligent version comparison and user promptsskipRuntimeUpdateparameter toValidateFunctionAppPublishto skip runtime updates during settings-only operationsColoredConsolefor consistencyelse ifImpact:
--publish-settings-only) preserve existing runtime configurationPull request checklist
Additional information
Architectural Improvements:
Project-based Runtime Detection: The system now detects the target framework from the project file (e.g., net9.0) and uses that for Azure runtime configuration, eliminating the hardcoded default that caused downgrades.
Centralized Runtime Updates: For Flex apps, runtime configuration is validated and updated in
ValidateFunctionAppPublishbefore code deployment, ensuring runtime compatibility before deploying code.Smart Version Management:
UpdateRuntimeConfigForFlexnow:Clean Separation:
PublishAppSettingsis now purely focused on app settings publishing, with runtime configuration keys removed from the settings dictionary but handled separately in the appropriate workflow stage.Testing:
Added unit tests in
PublishFunctionAppActionTests.cscovering:The tests use Moq to verify the
UpdateRuntimeConfigForFlexbehavior without requiring e2e infrastructure.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.