Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ upcoming
++++++
* 'az containerapp session code-interpreter execute': Extend maximum supported value of `--timeout-in-seconds` from 60 to 220.
* 'az containerapp job create': Fix message with `--help`
* 'az containerapp update': Disallow changing `--revisions-mode` to Labels.
* 'az containerapp up': Disallow changing `--revisions-mode` to Labels.

1.2.0b1
++++++
Expand Down
19 changes: 18 additions & 1 deletion src/containerapp/azext_containerapp/containerapp_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

from msrest.exceptions import DeserializationError

from ._clients import ManagedEnvironmentClient, ConnectedEnvironmentClient, ManagedEnvironmentPreviewClient
from ._clients import ManagedEnvironmentClient, ConnectedEnvironmentClient, ManagedEnvironmentPreviewClient, ContainerAppPreviewClient
from ._client_factory import handle_raw_exception, handle_non_404_status_code_exception, get_linker_client
from ._models import (
RegistryCredentials as RegistryCredentialsModel,
Expand Down Expand Up @@ -449,6 +449,23 @@ def construct_payload(self):
safe_set(self.new_containerapp, "properties", "template", "revisionSuffix", value=None)

if self.get_argument_revisions_mode():
if self.get_argument_revisions_mode().lower() == "labels":
# Transitioning into labels mode is complicated and we don't want to combine it with other updates.
# Check if the app was previously in labels mode. If not, throw an error saying to use Set-Mode instead.
containerapp_def = None
try:
containerapp_def = ContainerAppPreviewClient.show(cmd=self.cmd, resource_group_name=self.get_argument_resource_group_name(), name=self.get_argument_name())
except Exception as e:
handle_raw_exception(e)

if not containerapp_def:
raise ResourceNotFoundError("The containerapp '{}' does not exist".format(self.get_argument_name()))

if safe_get(containerapp_def, "properties", "configuration", "activeRevisionsMode").lower() != "labels":
raise ArgumentUsageError(
"The containerapp '{}' is not in labels mode. Please use `az containerapp revision set-mode` to switch to labels mode first.".format(
Copy link
Contributor

Choose a reason for hiding this comment

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

later we can remove "labels" value for "containerapp update" and "up" command.

Copy link
Contributor Author

@Tratcher Tratcher Jul 31, 2025

Choose a reason for hiding this comment

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

Good point, I had added activeRevisionsMode to up and update before I knew about set-mode, but we could remove them. The tricky part for up is that we do want to be able to create an app in labels mode.
In theory we could replicate the logic from set-mode here, but I'd rather not, switching modes is not a common operation.

self.get_argument_name()))

safe_set(self.new_containerapp, "properties", "configuration", "activeRevisionsMode", value=self.get_argument_revisions_mode())

if self.get_argument_target_label():
Expand Down
Loading
Loading