Skip to content

[Containerapp] az containerapp start, az containerapp stop: Add start and stop commands - #34402

Open
mlidodo wants to merge 4 commits into
Azure:devfrom
mlidodo:containerapp-startstop
Open

mlidodo wants to merge 4 commits into
Azure:devfrom
mlidodo:containerapp-startstop

Conversation

@mlidodo

@mlidodo mlidodo commented Nov 11, 2026 •

Copy link
Copy Markdown

🤖 PR Validation — ❌ Action needed

Breaking Changes Tests Suppressions
⚠️ None ❌ 128/130 ️✔️ None
⚠️AzureCLI-BreakingChangeTest
⚠️containerapp
rule cmd_name rule_message suggest_message
⚠️ 1001 - CmdAdd containerapp start cmd containerapp start added
⚠️ 1001 - CmdAdd containerapp stop cmd containerapp stop added
❌AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.14
️✔️acs
️✔️latest
️✔️3.12
️✔️3.14
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.14
️✔️ams
️✔️latest
️✔️3.12
️✔️3.14
️✔️apim
️✔️latest
️✔️3.12
️✔️3.14
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.14
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.14
️✔️aro
️✔️latest
️✔️3.12
️✔️3.14
️✔️backup
️✔️latest
️✔️3.12
️✔️3.14
️✔️batch
️✔️latest
️✔️3.12
️✔️3.14
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.14
️✔️billing
️✔️latest
️✔️3.12
️✔️3.14
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.14
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.14
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.14
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.14
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.14
️✔️config
️✔️latest
️✔️3.12
️✔️3.14
️✔️configure
️✔️latest
️✔️3.12
️✔️3.14
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.14
️✔️container
️✔️latest
️✔️3.12
️✔️3.14
❌containerapp
❌latest
❌3.12
Type Test Case Error Message Line
Failed test_start_and_stop_register_sensitive_value_transform self = <azure.cli.command_modules.containerapp.tests.latest.test_containerapp_start_stop_unit.ContainerAppStartStopTests testMethod=test_start_and_stop_register_sensitive_value_transform>

    def test_start_and_stop_register_sensitive_value_transform(self):
        loader = Mock()
        group = Mock()
>       loader.command_group.return_value.enter.return_value = group
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_start_stop_unit.py:90: 
                                        

self = <Mock name='mock.command_group()' id='140577717921856'>
name = 'enter'

    def getattr(self, name):
        if name in {'_mock_methods', '_mock_unsafe'}:
            raise AttributeError(name)
        elif self._mock_methods is not None:
            if name not in self._mock_methods or name in _all_magics:
                raise AttributeError("Mock object has no attribute %r" % name)
        elif _is_magic(name):
>           raise AttributeError(name)
E           AttributeError: enter

/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/unittest/mock.py:662: AttributeError
azure/cli/command_modules/containerapp/tests/latest/test_containerapp_start_stop_unit.py:86
Failed test_start_waits_for_async_operation self = <azure.cli.command_modules.containerapp.tests.latest.test_containerapp_start_stop_unit.ContainerAppStartStopTests testMethod=test_start_waits_for_async_operation>

    def test_start_waits_for_async_operation(self):
        operation_url = "https://management.azure.com/operations/123"
        response = Mock(status_code=202, headers={"azure-asyncoperation": operation_url})
        final_response = Mock()
        final_response.json.return_value = {"name": "app"}
        request_url = "{}/start?api-version={}".format(
            self.resource_url, _clients.ContainerAppClient.api_version)
        resource_url = "{}?api-version={}".format(
            self.resource_url, _clients.ContainerAppClient.api_version)
    
        with patch.object(_clients, "get_subscription_id", return_value="subscription"), <br>                patch.object(_clients, "send_raw_request", side_effect=[response, final_response]) as send_request, <br>                patch.object(_clients, "poll_status") as poll_status:
            result = _clients.ContainerAppClient.start(self.cmd, "group", "app")
    
>       self.assertEqual(result, {"name": "app"})
E       AssertionError: None != {'name': 'app'}

src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_start_stop_unit.py:54: AssertionError
azure/cli/command_modules/containerapp/tests/latest/test_containerapp_start_stop_unit.py:38
❌3.14
Type Test Case Error Message Line
Failed test_start_and_stop_register_sensitive_value_transform self = <azure.cli.command_modules.containerapp.tests.latest.test_containerapp_start_stop_unit.ContainerAppStartStopTests testMethod=test_start_and_stop_register_sensitive_value_transform>

    def test_start_and_stop_register_sensitive_value_transform(self):
        loader = Mock()
        group = Mock()
>       loader.command_group.return_value.enter.return_value = group
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_start_stop_unit.py:90: 
                                        

self = <Mock name='mock.command_group()' id='139917884190944'>
name = 'enter'

    def getattr(self, name):
        if name in {'_mock_methods', '_mock_unsafe'}:
            raise AttributeError(name)
        elif self._mock_methods is not None:
            if name not in self._mock_methods or name in _all_magics:
                raise AttributeError("Mock object has no attribute %r" % name)
        elif _is_magic(name):
>           raise AttributeError(name)
E           AttributeError: enter

/opt/hostedtoolcache/Python/3.14.2/x64/lib/python3.14/unittest/mock.py:698: AttributeError
azure/cli/command_modules/containerapp/tests/latest/test_containerapp_start_stop_unit.py:86
Failed test_start_waits_for_async_operation self = <azure.cli.command_modules.containerapp.tests.latest.test_containerapp_start_stop_unit.ContainerAppStartStopTests testMethod=test_start_waits_for_async_operation>

    def test_start_waits_for_async_operation(self):
        operation_url = "https://management.azure.com/operations/123"
        response = Mock(status_code=202, headers={"azure-asyncoperation": operation_url})
        final_response = Mock()
        final_response.json.return_value = {"name": "app"}
        request_url = "{}/start?api-version={}".format(
            self.resource_url, _clients.ContainerAppClient.api_version)
        resource_url = "{}?api-version={}".format(
            self.resource_url, _clients.ContainerAppClient.api_version)
    
        with patch.object(_clients, "get_subscription_id", return_value="subscription"), <br>                patch.object(_clients, "send_raw_request", side_effect=[response, final_response]) as send_request, <br>                patch.object(_clients, "poll_status") as poll_status:
            result = _clients.ContainerAppClient.start(self.cmd, "group", "app")
    
>       self.assertEqual(result, {"name": "app"})
E       AssertionError: None != {'name': 'app'}

src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_start_stop_unit.py:54: AssertionError
azure/cli/command_modules/containerapp/tests/latest/test_containerapp_start_stop_unit.py:38
️✔️core
️✔️latest
️✔️3.12
️✔️3.14
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.14
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.14
️✔️dls
️✔️latest
️✔️3.12
️✔️3.14
️✔️dms
️✔️latest
️✔️3.12
️✔️3.14
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.14
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.14
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.14
️✔️find
️✔️latest
️✔️3.12
️✔️3.14
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.14
️✔️identity
️✔️latest
️✔️3.12
️✔️3.14
️✔️iot
️✔️latest
️✔️3.12
️✔️3.14
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.14
️✔️lab
️✔️latest
️✔️3.12
️✔️3.14
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.14
️✔️maps
️✔️latest
️✔️3.12
️✔️3.14
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.14
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.14
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.14
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.14
️✔️network
️✔️latest
️✔️3.12
️✔️3.14
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.14
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.14
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.14
️✔️profile
️✔️latest
️✔️3.12
️✔️3.14
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.14
️✔️redis
️✔️latest
️✔️3.12
️✔️3.14
️✔️relay
️✔️latest
️✔️3.12
️✔️3.14
️✔️resource
️✔️latest
️✔️3.12
️✔️3.14
️✔️role
️✔️latest
️✔️3.12
️✔️3.14
️✔️search
️✔️latest
️✔️3.12
️✔️3.14
️✔️security
️✔️latest
️✔️3.12
️✔️3.14
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.14
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.14
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.14
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.14
️✔️sql
️✔️latest
️✔️3.12
️✔️3.14
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.14
️✔️storage
️✔️latest
️✔️3.12
️✔️3.14
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.14
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.14
️✔️util
️✔️latest
️✔️3.12
️✔️3.14
️✔️vm
️✔️latest
️✔️3.12
️✔️3.14

Related command
az containerapp start, az containerapp stop

Description
Add commands to start and stop Container Apps, including support for --no-wait and polling for completion. Closes #27433

Testing Guide
Unit tests cover no-wait behavior and both async polling response paths.

History Notes
[Containerapp] az containerapp start, az containerapp stop: Add start and stop commands


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

Copilot AI balanced review requested due to automatic review settings November 11, 2026 18:20
@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 Nov 11, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

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

@mlidodo

mlidodo commented Nov 11, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

🟡 Changes recommended

Start and stop can expose sensitive values, report success before completion, or fail after the action succeeds when app-read permission is absent.

3 open issues
What changed in this PR

Adds az containerapp start and az containerapp stop to the existing Container Apps command module, addressing #27433.

Changes:

  • Registers both commands with --no-wait support and help examples.
  • Adds shared REST request handling and asynchronous completion polling.
  • Adds unit tests for no-wait behavior and both polling response paths.
File Description
src/​azure-cli/​azure/​cli/​command_modules/​containerapp/​tests/​latest/​test_containerapp_start_stop_unit.py Tests no-wait requests and both polling paths.
src/​azure-cli/​azure/​cli/​command_modules/​containerapp/​custom.py Adds command handlers with error handling.
src/​azure-cli/​azure/​cli/​command_modules/​containerapp/​commands.py Registers start and stop commands.
src/​azure-cli/​azure/​cli/​command_modules/​containerapp/​_help.py Adds command descriptions and examples.
src/​azure-cli/​azure/​cli/​command_modules/​containerapp/​_clients.py Implements shared start/stop requests and polling.

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.

Support az containerapp stop and az containerapp start

5 participants