Fix remote container build fallback - #9939
Conversation
Build and package local images after an ACR Tasks scheduling refusal, preserve failure diagnostics, and synchronize shared runtime selection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6211a2e6-c280-4468-a804-4b019c435e9b
|
Azure Pipelines: Successfully started running 1 pipeline(s). 21 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The narrowed fallback behavior conflicts with the linked issue’s expected handling of terminal build failures.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
cli/azd/pkg/project/container_helper.go — The linked issue’s reproduction reaches RunStatusFailed after scheduling succeeds, but this type… |
What changed in this PR
Fixes remote container-build recovery and makes runtime selection concurrency-safe.
Changes:
- Restricts fallback to ACR scheduling refusal.
- Rebuilds/packages locally when needed while preserving both errors.
- Adds concurrency, lifecycle, diagnostic, and documentation coverage.
| File | Description |
|---|---|
schemas/v1.0/azure.yaml.json |
Updates stable schema guidance. |
schemas/alpha/azure.yaml.json |
Updates alpha schema guidance. |
docs/reference/azure-yaml-schema.md |
Documents fallback behavior. |
cli/azd/pkg/tools/docker/docker.go |
Synchronizes runtime selection. |
cli/azd/pkg/tools/docker/docker_concurrency_test.go |
Tests concurrent runtime access. |
cli/azd/pkg/project/container_helper.go |
Implements local recovery lifecycle. |
cli/azd/pkg/project/container_helper_test.go |
Removes obsolete fallback test. |
cli/azd/pkg/project/container_helper_remote_build_test.go |
Adds comprehensive fallback tests. |
cli/azd/pkg/containerregistry/remote_build.go |
Types eligible scheduling failures. |
cli/azd/pkg/containerregistry/remote_build_test.go |
Tests error classification. |
cli/azd/internal/grpcserver/container_service_test.go |
Tests combined-error propagation. |
cli/azd/docs/concurrency-model.md |
Documents Docker CLI locking. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The fallback policy, concurrency changes, documentation, and relevant failure paths are consistently implemented and tested.
Review tier: Balanced
Findings: None
Issues resolved since last review (1)
| Severity | Finding |
|---|---|
cli/azd/pkg/project/container_helper.go — The linked issue’s reproduction reaches RunStatusFailed after scheduling succeeds, but this type… View resolved comment |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 21 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|

Fixes #9749
Summary
This PR fixes local fallback for remote container builds. Previously, fallback tried to publish an image that the remote-build lifecycle never built.
Fallback now runs automatically only when ACR rejects scheduling with
TasksOperationsNotAllowed. It builds and packages locally or publishes a supplied local image. Other remote errors do not trigger fallback, and both failures are preserved if local recovery fails.The change also synchronizes Docker/Podman runtime selection for parallel publishes and updates the configuration documentation.
Why fallback is narrower
The failing-Dockerfile reproduction in #9749 now returns the original ACR failure without attempting local recovery. Automatic recovery addresses the ACR Tasks restrictions behind #4618, rather than retrying every remote error.
A failed build does not establish that local recovery will help. Errors retrieving logs or status can also leave a remote build running, so starting another build could duplicate work. These failures and cancellation do not trigger fallback.
Screenshots
Testing
Targeted tests passed under the race detector, including 20 repeated parallel fallback runs. CLI build, Go lint and modernization checks, spelling, and schema validation passed.
Live ACR publishing succeeded with a valid Dockerfile. A failing
RUNpreserved the original error, with no local Docker/Podman execution in either scenario. Test resources were deleted. Scheduling-refusal fallback is covered by mocks.Tested manually (see screenshots above) with new Azure free trial account.