Context
A release script queued an image build in Azure Container Registry and wanted the run ID, so it could wait for that exact run and take the image digest from it:
$run = az acr build --registry <registry> --image <repo>:<tag> . --no-wait --output json | ConvertFrom-Json$run.runId # expected the queued runEvery build failed with “returned no run ID”. The builds themselves were queued and ran.
Insight 1: --no-wait prints no result
With --no-wait, the command exits 0 and writes nothing to stdout. The run ID appears only in a warning on stderr (Queued a build with ID: <id>), which is a log line, not output.
To get the run from the command that queued it, use --no-logs instead. The CLI then waits for the run and returns it:
$run = az acr build --registry <registry> --image <repo>:<tag> . --no-logs --output json | ConvertFrom-Json$run.runId$run.status # Succeeded$run.outputImages[0].digest # sha256:...az acr task logs --registry <registry> --run-id $run.runId # the log is not streamed with --no-logsA run that does not succeed exits 1 with empty stdout. Only the error text names it: The run with ID '<id>' finished with unsuccessful status ....
Documented: the
az acrreference says--no-waitmakesaz acr build/az acr runreturn immediately after queuing, and that--no-logssuppresses the logs. A signing tutorial shows by example thataz acr build ... --no-logs --query "outputImages[0].digest" -o tsvyields the digest. (az acr reference, sign, build and push tutorial)Observed (2026-11-30, Azure CLI 2.88.0): no page says that
--no-waitdrops the result. In a CI run,az acr build --no-wait --output jsonexited 0 with empty stdout.--no-logs --output jsonreturned the finished run withrunId,statusandoutputImagesforaz acr build, and the run with itsrunIdfor a two-imageaz acr run;az acr task show-runthen listed one digest per image. A failing build and a failing run both exited 1 with no JSON.Read in the CLI source, not tested beyond ACR: the discard is in the CLI core, not in the
acrmodule._run_jobsets the result toNonefor any command that supports--no-waitwhen the flag is passed, so the same should hold for every such command.
Insight 2: the fake CLI printed what the real one never prints
The script had tests, and they passed. The stand-in az used by the tests answered the --no-wait call with {"runId":"run1","status":"Queued"}. It was written from the output the author expected, so the tests proved the script against an assumption.
What would have caught it:
- Capture the real command once for each flag combination the code relies on: stdout, stderr and exit code, for success and for failure. Build the fake from that capture.
- Keep stdout and stderr apart in the fake. Here the ID was real, but on the wrong stream.
- After correcting a fake, run the suite against the old code first. It must fail with the production error. If it stays green, the fake still differs from the real tool.