Skip to main content
Guide

Labels and selectors

Labels are key-value metadata on sandboxes. Add labels when you create sandboxes, then use selectors to find workers by tenant, role, job, or environment.

Create sandboxes with labels​

Set labels when you create a sandbox. Use stable keys that your automation can query later.

  1. Open the group at sandboxes.azure.com/sandbox-groups and select Sandboxes.
  2. Select Create.
  3. Pick a disk image, such as ubuntu.
  4. Open Labels and add tenant, role, and any job-specific labels.
  5. Select Create.
aca sandbox create --label name=worker-0 --label tenant=t42 --label role=worker
aca sandbox create --label name=worker-1 --label tenant=t42 --label role=worker
aca sandbox create --label name=control-0 --label tenant=t42 --label role=control

Filter in the portal and with selectors​

In the portal Sandboxes list, the search box does substring matching across the sandbox ID, label keys, and label values. It is not an exact key-value selector and does not require multiple labels to match together.

  1. Open the group and select Sandboxes.
  2. Use the search box to enter text from a sandbox ID, label key, or label value, such as t42 or worker.
  3. Select a sandbox to review its labels on the detail page.
  4. Clear the search box to return to the full list.
aca sandbox list -l "tenant=t42,role=worker"
aca sandbox list -l "tenant=t42,role=control"

Read and clean up labeled sandboxes​

Use labels to clean up a tenant or job batch without tracking each sandbox ID separately.

  1. Open the filtered Sandboxes list.
  2. Select each matching sandbox.
  3. Select Delete and confirm.
IDS=$(aca sandbox list -l "tenant=t42" -o json | jq -r '.[].id')
for id in $IDS; do
aca sandbox delete --id "$id" --yes
done

Label conventions​

Label keyExample valueUse
nameworker-1Human-readable selector for CLI workflows
roleworkerSeparate workers from control sandboxes
tenantt42Isolate one tenant or test run
job-idabc123Delete a batch after a job completes