Skip to content

[App Service] Fix az functionapp config appsettings set: stop emitting misleading Invalid version warning for Java 21/25 and .NET-isolated apps#33380

Open
ahmedmuhsin wants to merge 1 commit into
Azure:devfrom
ahmedmuhsin:fix/functionapp-runtime-version-normalization
Open

[App Service] Fix az functionapp config appsettings set: stop emitting misleading Invalid version warning for Java 21/25 and .NET-isolated apps#33380
ahmedmuhsin wants to merge 1 commit into
Azure:devfrom
ahmedmuhsin:fix/functionapp-runtime-version-normalization

Conversation

@ahmedmuhsin
Copy link
Copy Markdown

Related command

az functionapp config appsettings set

(also any other command that goes through _FunctionAppStackRuntimeHelper.resolve, but the customer-facing symptom is on appsettings set because update_app_settings_functionapp calls check_language_runtime first)

Description

Fixes #33379.

az functionapp config appsettings set on a Linux Java 21 (or Java 25) Function App emits a WARNING: Invalid version: 21 for runtime java and os linux ... even though the app is healthy and the setting is applied. Same false-positive can be reproduced on .NET-isolated apps when the stored version is 8.0 (the Stacks API returns "8" for that runtime).

Root cause: _FunctionAppStackRuntimeHelper.resolve in appservice/custom.py validates a runtime version by exact-matching against the Stacks API output. When that fails, it consults a hand-maintained old_to_new_version map. The map covered Java up to 17 and a couple of .NET swaps, but Java 21/25 were never added — so Java|21 (Portal/Bicep style) never reconciles with API value "21.0". check_language_runtime swallows the ValidationError as a logger.warning, producing the customer-visible noise.

Replace the static map with three generic numeric normalization rules that are tried only when the direct lookup fails — and only as candidates that must still exist in the actual runtimes list returned by the API:

  • "21""21.0" (bare integer → decimal form)
  • "8.0""8" (decimal form → bare integer)
  • "1.8""8.0" (legacy Java backwards compatibility)

These three rules cover every entry the old map had and stay self-healing for future Java/.NET majors. A genuinely unknown version ("99", "21.5", etc.) still produces the existing Invalid version: ValidationError.

This is the Functions-side analogue to PR #32461, which removed similar hardcoded Java lists from the Web Apps _StackRuntimeHelper. The PR's _get_java_versions_from_* helpers are not borrowed here because the Functions code path doesn't walk the stacks tree the way the Web Apps listing does — a small normalization in resolve() is sufficient.

Testing Guide

New tests in test_functionapp_commands_thru_mock.py cover:

  1. Java bare integer → decimal match ("21""21.0") — repros the customer's bug
  2. Java 25 — future-proofing assertion (the fix must work without code changes)
  3. .NET-isolated decimal → bare integer match ("8.0""8")
  4. Legacy Java "1.8""8.0" still works
  5. Already-canonical input is returned untouched (no normalization runs)
  6. Unknown major version still raises ValidationError
  7. Unknown minor version ("21.5") still raises ValidationError
  8. disable_version_error=True still suppresses the error and returns None

Run locally with:

azdev test appservice --tests TestFunctionAppStackRuntimeHelperResolve

Or:

pytest src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_functionapp_commands_thru_mock.py::TestFunctionAppStackRuntimeHelperResolve -v

All 8 new tests pass; the rest of the file (31 tests total) and the sibling test_webapp_commands_thru_mock.py (50 tests) still pass. azdev style appservice passes.

History Notes

[App Service] Fix #33379: az functionapp config appsettings set: stop emitting a misleading "Invalid version" warning for Java/.NET runtime versions stored without a matching decimal suffix

…ntime version suffix

Replaces the hand-maintained old_to_new_version map in _FunctionAppStackRuntimeHelper.resolve with three generic numeric normalization rules that bridge bare-integer and X.0 forms in both directions, plus the legacy Java 1.8 -> 8.0 case. Each candidate is only accepted if it exists in the API-returned runtime list, so genuinely invalid versions still raise the existing 'Invalid version' error.

Fixes the misleading 'Invalid version: 21 for runtime java' warning emitted when running az functionapp config appsettings set on Linux Java 21/25 apps. Same false positive could be reproduced on .NET-isolated apps when the persisted version was stored as 8.0 instead of 8.
Copilot AI review requested due to automatic review settings May 14, 2026 16:23
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Azure CLI Full Test Starting...

Thanks for your contribution!

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Breaking Change Starting...

Thanks for your contribution!

@ahmedmuhsin ahmedmuhsin changed the title [App Service] Fix az functionapp config appsettings set: stop emitting misleading Invalid version warning for Java 21/25 and .NET-isolated apps [App Service] Fix az functionapp config appsettings set: stop emitting misleading Invalid version warning for Java 21/25 and .NET-isolated apps May 14, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Auto-Assign Auto assign by bot label May 14, 2026
@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented May 14, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@berndverst
Copy link
Copy Markdown
Member

I've been following along for a few days (since the original emails about the issue). I'm the current Functions Sev2 on-call. This LGTM.

@yonzhan yonzhan assigned yanzhudd and unassigned zhoxing-ms and ReaNAiveD May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az functionapp config appsettings set emits misleading "Invalid version: 21 for runtime java" warning on Linux Java 21/25 apps

6 participants