From b77cab4efc65889e97cbd21f537575dbbe00cd18 Mon Sep 17 00:00:00 2001 From: cheng zhe <740360112@qq.com> Date: Wed, 9 Sep 2026 16:38:08 +0800 Subject: [PATCH 1/2] [Containerapp] az containerapp logs show: Use replica log stream endpoint Use the replica container logStreamEndpoint for console logs so express apps do not depend on eventStreamEndpoint. Continue using the container app eventStreamEndpoint for system logs and document the fix. --- src/azure-cli/HISTORY.rst | 1 + .../cli/command_modules/containerapp/custom.py | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/azure-cli/HISTORY.rst b/src/azure-cli/HISTORY.rst index c222025df06..02b5542599c 100644 --- a/src/azure-cli/HISTORY.rst +++ b/src/azure-cli/HISTORY.rst @@ -68,6 +68,7 @@ Release History **Container app** * `az containerapp job update`: Fix crash for `--no-wait` parameter (#33807) +* `az containerapp logs show`: Use the replica log stream endpoint for console logs **Key Vault** diff --git a/src/azure-cli/azure/cli/command_modules/containerapp/custom.py b/src/azure-cli/azure/cli/command_modules/containerapp/custom.py index 8c479bded7e..82bd0fe7ecc 100644 --- a/src/azure-cli/azure/cli/command_modules/containerapp/custom.py +++ b/src/azure-cli/azure/cli/command_modules/containerapp/custom.py @@ -3573,18 +3573,20 @@ def stream_containerapp_logs(cmd, resource_group_name, name, container=None, rev if output_format and output_format != "json": raise MutuallyExclusiveArgumentError("--type: only json logs supported for system logs") - sub = get_subscription_id(cmd.cli_ctx) token_response = ContainerAppClient.get_auth_token(cmd, resource_group_name, name) token = token_response["properties"]["token"] - base_url = ContainerAppClient.show(cmd, resource_group_name, name)["properties"]["eventStreamEndpoint"] - base_url = base_url[:base_url.index("/subscriptions/")] - if kind == LOG_TYPE_CONSOLE: - url = (f"{base_url}/subscriptions/{sub}/resourceGroups/{resource_group_name}/containerApps/{name}" - f"/revisions/{revision}/replicas/{replica}/containers/{container}/logstream") + replica_payload = ContainerAppClient.get_replica(cmd, resource_group_name, name, revision, replica) + containers = safe_get(replica_payload, "properties", "containers", default=[]) + container_name = container or "" + container_info = next((c for c in containers if c["name"].lower() == container_name.lower()), None) + if not container_info: + raise ResourceNotFoundError(f"Could not find container '{container}' in replica '{replica}'") + url = container_info["logStreamEndpoint"] else: - url = f"{base_url}/subscriptions/{sub}/resourceGroups/{resource_group_name}/containerApps/{name}/eventstream" + container_app = ContainerAppClient.show(cmd, resource_group_name, name) + url = container_app["properties"]["eventStreamEndpoint"] logger.info("connecting to : %s", url) request_params = {"follow": str(follow).lower(), From b3a8726681ba66f1f16fd6a787533252577703d7 Mon Sep 17 00:00:00 2001 From: cheng zhe <740360112@qq.com> Date: Wed, 9 Sep 2026 16:45:56 +0800 Subject: [PATCH 2/2] update --- src/azure-cli/HISTORY.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/src/azure-cli/HISTORY.rst b/src/azure-cli/HISTORY.rst index 02b5542599c..c222025df06 100644 --- a/src/azure-cli/HISTORY.rst +++ b/src/azure-cli/HISTORY.rst @@ -68,7 +68,6 @@ Release History **Container app** * `az containerapp job update`: Fix crash for `--no-wait` parameter (#33807) -* `az containerapp logs show`: Use the replica log stream endpoint for console logs **Key Vault**