Skip to content

[Container app] az containerapp up: Fix existing app being re-created when the existence check fails - #34310

Open
nabeleon94 wants to merge 1 commit into
Azure:devfrom
nabeleon94:containerapp-up-only-create-on-not-found
Open

nabeleon94 wants to merge 1 commit into
Azure:devfrom
nabeleon94:containerapp-up-only-create-on-not-found

Conversation

@nabeleon94

@nabeleon94 nabeleon94 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes Tests Suppressions
️✔️ None ️✔️ 130/130 ⚠️ 1 added

This PR adds warning or check suppressions. Fix the underlying warning where possible and justify each remaining suppression in a code comment or the PR description.

1 added suppression
File Line Kind Code
src/azure-cli/azure/cli/command_modules/containerapp/custom.py 3752 pylint except Exception as e: # pylint: disable=broad-except

Related command
az containerapp up

Description
Fixes #34193

containerapp_up_logic() GETs the app to choose between update and create, but wrapped that GET in a bare except: pass. When the GET failed for any reason other than "not found" (throttling, a transient 5xx, a network or token error), an existing app was treated as missing. up then sent a full create PUT built only from its own arguments, which reset the app's system-assigned identity, ingress, secrets and scale, as described in the issue.

The GET now goes through the module's existing handle_non_resource_not_found_exception() helper:

  • ResourceNotFound (404 for a missing app): same as before, falls through to create.
  • Any other ARM error is raised as CLIInternalError('(code) message'), and non-ARM exceptions are re-raised, so up fails without overwriting the app.

The first existence check in _up_utils.py (get_container_app_if_exists) only chooses the "Updating/Creating" log line, so I left it unchanged.

Note: the containerapp extension in azure-cli-extensions has the same bare except in its own containerapp_up_logic (azext_containerapp/custom.py).

Testing Guide
New unit test containerapp/tests/latest/test_containerapp_up_logic_unit.py (mocks ContainerAppClient.show):

  • existing app → update, no create
  • 404 ResourceNotFound → create
  • 429 TooManyRequests → raises CLIInternalError, no create
  • requests ConnectionError → re-raised, no create

Before the fix, the last two fail (create is called and nothing is raised): 2 failed, 2 passed. After the fix: 4 passed. test_containerapp_utils.py and test_containerapp_validators.py still pass, and flake8 (repo .flake8) is clean. pylint (repo pylintrc) reports no new findings on custom.py. The up scenario tests are @live_only and weren't run.

History Notes
[Container app] az containerapp up: Fix existing app being re-created with default settings when the existence check fails for a reason other than not found


This checklist is used to make sure that common guidelines for a pull request are followed.

…ed when the existence check fails

containerapp_up_logic() swallowed every exception from the GET that decides
between update and create, so a throttled/transient/network failure made an
existing app look missing and up sent a full create PUT, resetting identity,
ingress, secrets and scale. Only fall through to create on ResourceNotFound;
re-raise anything else.

Fixes Azure#34193
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Oct 30, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the change intended to prevent failed app-existence checks from overwriting an existing app’s configuration.

No open issues 🎉

What changed in this PR

Fixes #34193 by preventing az containerapp up from treating a failed existence check as a missing app, which could overwrite an existing app’s configuration.

Changes:

  • Uses the existing error handler to allow creation after ResourceNotFound while propagating other lookup failures.
  • Adds unit tests covering existing apps, missing apps, throttling, and connection errors.
File Description
src/​azure-cli/​azure/​cli/​command_modules/​containerapp/​tests/​latest/​test_containerapp_up_logic_unit.py Adds regression tests for create/update selection and lookup-error propagation.
src/​azure-cli/​azure/​cli/​command_modules/​containerapp/​custom.py Replaces silent exception handling with the existing not-found-aware handler.

Review effort: Balanced

@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-observability-squad ContainerApp customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az containerapp up silently re-creates an existing container app when its second existence check fails, wiping identity, ingress, secrets and scale

5 participants