Skip to content

[containerapp] "az containerapp show" does not return exit code 3 when the Container App does not exist #10375

Description

@x-engineering-agent

Source: Azure/azure-cli#28318 (by masashiyonekawa)
Affected extension: containerapp (src/containerapp/)


<<UNTRUSTED:issue-28318>>

Issue #28318 (by masashiyonekawa)

Title

"az containerapp show" does not return exit code 3 when the Container App does not exist

Body

Describe the bug

The az containerapp show command errors with exit code 1 when no Container App exists.

Related command

az containerapp show

Errors

'''
$ az containerapp show --name CONTAINER_APP_NAME --resource-group RG --subscription SUBSCRIPTION
The behavior of this command has been altered by the following extension: containerapp
(ResourceNotFound) The Resource 'Microsoft.App/containerApps/CONTAINER_APP_NAME' under resource group 'RG' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix

$ echo $?
1
'''

Issue script & Debug output

'''
$ az containerapp show --name CONTAINER_APP_NAME --resource-group RG --subscription SUBSCRIPTION --debug
cli.knack.cli: Command arguments: ['containerapp', 'show', '--name', 'CONTAINER_APP_NAME', '--resource-group', 'RG', '--subscription', 'b
43fdb54-b148-4d60-a89f-a68fa05b3fb1', '--debug']
cli.knack.cli: init debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x01382898>, <function OutputProducer.on_global_a
rguments at 0x016A6988>, <function CLIQuery.on_global_arguments at 0x016CC7A8>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'containerapp': ['azext_containerapp', 'azure.cli.command_modules.containerapp', 'azure.cli.command_modules.serviceconnector']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: containerapp 0.294 36 115
cli.azure.cli.core: serviceconnector 0.110 20 299
cli.azure.cli.core: Total (2) 0.403 56 414
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: containerapp 0.014 30 81 DIRECTORY
cli.azure.cli.core: Total (1) 0.014 30 81
cli.azure.cli.core: Loaded 74 groups, 471 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : containerapp show
cli.azure.cli.core: Command table: containerapp show
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x03753578>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'DIRECTORY.azure\commands\2024-02-07.19-03-22.containerapp_show.24772.log'.
az_command_data_logger: command args: containerapp show --name {} --resource-group {} --subscription {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x037671B8>]
cli.knack.commands: Configured default 'RG' for arg resource_group_name
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x0378F898>, <function register_cache_arguments..add_cache_arguments at 0x0378F8E8>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x016A69D8>, <function CLIQuery.handle_query_parameter at 0x016CC7F8>, <function register_ids_argument..parse_ids_arguments at 0x0378F7A8>]
az_command_data_logger: extension name: containerapp
az_command_data_logger: extension version: 0.3.46
cli.azure.cli.core.commands: The behavior of this command has been altered by the following extension: containerapp
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=ResourceManagementClient
cli.azure.cli.core.auth.persistence: build_persistence: location='DIRECTORY\.azure\msal_token_cache.bin', encrypt=True
cli.azure.cli.core.auth.binary_cache: load: DIRECTORY.azure\msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: openid_config = {'token_endpoint': 'https://login.microsoftonline.com/ec449cfa-3a33-4fde-ba33-ce11d541198d/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/ec449cfa-3a33-4fde-ba33-ce11d541198d/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/ec449cfa-3a33-4fde-ba33-ce11d541198d/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/ec449cfa-3a33-4fde-ba33-ce11d541198d/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/ec449cfa-3a33-4fde-ba33-ce11d541198d/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/ec449cfa-3a33-4fde-ba33-ce11d541198d/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/ec449cfa-3a33-4fde-ba33-ce11d541198d/kerberos', 'tenant_region_scope': 'AS', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
msal.application: Broker enabled? False
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_authentication: UserCredential.get_token: scopes=('https://management.core.windows.net//.default',), claims=None, kwargs={}
0m
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: 32685137-b208-4de3-b279-6098c9be31f6
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/SUBSCRIPTION/providers/Microsoft.App?api-version=2022-09-01'
cli.azure.cli.core.sdk.policies: Request method: 'GET'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '206507b4-c5a0-11ee-bee4-845cf32c9768'
cli.azure.cli.core.sdk.policies: 'CommandName': 'containerapp show'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '--name --resource-group --subscription --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.57.0 (MSI) azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.11.7 (Windows-10-10.0.19045-SP0)'
cli.azure.cli.core.sdk.policies: 'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/SUBSCRIPTION/providers/Microsoft.App?api-version=2022-09-01 HTTP/1.1" 200 19416
cli.azure.cli.core.sdk.policies: Response status: 200
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
cli.azu
... [truncated, original was 40643 chars]

Comments

Comment by Yong Zhang (@yonzhan)

Thank you for opening this issue, we will look into it.

Comment by @microsoft-github-policy-service[bot]

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc calvin (@calvinsID).

Comment by Greedygre (@Greedygre)

Hi masashiyonekawa

Containerapp show command return exit code 1 when resource not exist, which should be exit code 3.
I investigated it and found this is because Containerapp is using generic REST Client to call the ARM endpoint, so it will not be handled by following code:

'''
def show_exception_handler(ex):
if getattr(getattr(ex, 'response', ex), 'status_code', None) == 404:
import sys
from azure.cli.core.azlogging import CommandLoggerContext
from azure.cli.core.azclierror import ResourceNotFoundError
with CommandLoggerContext(logger):
az_error = ResourceNotFoundError(getattr(ex, 'message', ex))
az_error.print_error()
az_error.send_telemetry()
sys.exit(3)
raise ex
'''

Currently all exit code with error is 1.
Thanks.

Comment by masashiyonekawa

this also happens with the az containerapp env show command
<<END:issue-28318>>

Activity

  1. added
    questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
    customer-reportedIssues that are reported by GitHub users external to the Azure organization.
    on Sep 21, 2026
  2. yonzhan commented on Sep 21, 2026

    @yonzhan
    Collaborator

    Thank you for opening this issue, we will look into it.

  3. added a commit that references this issue on Sep 21, 2026
    0ab4838
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Auto-AssignAuto assign by botContainerAppService AttentionThis issue is responsible by Azure service team.act-observability-squadcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions