Skip to main content
Guide

Sandbox lifecycle

Stop a sandbox when work pauses, resume it when work returns, and tune idle policies so compute matches the time your workload is active.

Lifecycle settings control when sandbox compute runs. Stopped sandboxes keep disk state and stop billing for compute.

Prepare a sandbox

Create a sandbox and capture its ID into $ID. Every CLI snippet on this page acts on $ID.

aca sandbox create \
--disk ubuntu \
--label name=lifecycle-demo

ID=$(aca sandbox list -l name=lifecycle-demo -o json | jq -r '.[0].id')

echo "$ID"

Set lifecycle policy

Set auto-suspend to pause an idle sandbox after a timeout. Auto-delete cleans up a sandbox after a longer interval.

  1. In the ACA Sandboxes portal, open your sandbox group.
  2. Select Sandboxes.
  3. Select the sandbox, then select Lifecycle.
  4. Set Auto-suspend to the idle timeout you want, such as 60 seconds.
  5. Select Save.
aca sandbox lifecycle set --id "$ID" --auto-suspend enable --mode Memory --idle-timeout-seconds 60

Stop a sandbox

Stop a sandbox to pause compute while keeping its disk state.

  1. In the ACA Sandboxes portal, open your sandbox group.
  2. Select Sandboxes.
  3. Select the sandbox row.
  4. Select Stop.
  5. Wait for the state to change to Stopped.
aca sandbox create --disk ubuntu --label name=lifecycle-demo

aca sandbox stop -l name=lifecycle-demo

Resume a sandbox

Resume a stopped sandbox before running commands in it.

  1. In the ACA Sandboxes portal, open your sandbox group.
  2. Select Sandboxes.
  3. Select the stopped sandbox.
  4. Select Resume.
  5. Wait for the state to return to Running.
aca sandbox resume --id "$ID"

aca sandbox exec --id "$ID" -c "uptime"

Read lifecycle state

Use the sandbox state to decide whether to stop, resume, or run work.

  1. In the ACA Sandboxes portal, open your sandbox group.
  2. Select Sandboxes.
  3. Review the State column.
  4. Select a sandbox for detailed lifecycle state.
aca sandbox get --id "$ID" -o json | jq -r '.state'