feat: add localFallback option for Docker remote build - #7041
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements a localFallback option for Docker remote builds in azd. When remoteBuild: true and localFallback: true are set in azure.yaml, if the remote ACR build fails, azd automatically retries with a local Docker build and displays a warning. This addresses #4618, where users on free-trial subscriptions (which don't support ACR Tasks) had to manually remove remoteBuild: true to work around deployment failures.
Changes:
- Adds
LocalFallbackfield toDockerProjectOptionsstruct and propagates it through proto/mapper layers - Implements fallback logic in
ContainerHelper.Publish()usingux.WarningMessage - Adds
localFallbackto the JSON schema at both docker-level and service-level
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
schemas/v1.0/azure.yaml.json |
Adds localFallback to both the service-level and the docker definition blocks |
cli/azd/pkg/project/framework_service_docker.go |
Adds LocalFallback bool field to DockerProjectOptions struct |
cli/azd/pkg/project/container_helper.go |
Adds fallback logic: if runRemoteBuild fails and LocalFallback is set, displays a warning and calls publishLocalImage |
cli/azd/pkg/project/container_helper_test.go |
New test verifying warning is shown and local build runs when remote build fails |
cli/azd/pkg/project/mapper_registry.go |
Maps LocalFallback field in all three proto↔Go conversion functions |
cli/azd/grpc/proto/models.proto |
Adds local_fallback as field number 10 to DockerProjectOptions message |
cli/azd/pkg/azdext/models.pb.go |
Generated protobuf code: adds LocalFallback field and GetLocalFallback() accessor |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Since adding a new field would require to update all templates to benefit from this, I would consider making the fallback the default behavior for However, we could also make azd to check the SKU from the ACR defined in the infrastructure when remoteBuild is enabled and warn folks about it. Maybe as part of |
|
wbreza
left a comment
There was a problem hiding this comment.
📋 Code Review — PR #7041
Thanks for taking the time to better our docs! Great work pivoting to automatic fallback without a separate config field — this is cleaner and matches the team's consensus.
I verified the implementation against the codebase and found one significant concern around CI behavior, plus a few cleanup items.
✅ What Looks Good
- Automatic fallback without new config is the right design — avoids ambiguous flag combinations
- Docker/Podman availability check before fallback is solid
- Original remote error preserved in the warning message
- Proto field properly reserved (field 10 + name)
- Test correctly uses
linux/arm64platform to trigger remote build failure
Summary
| Priority | Count |
|---|---|
| High | 1 |
| Medium | 2 |
| Low | 1 |
| Total | 4 |
Overall Assessment: Comment — the CI fallback behavior deserves discussion, and there are a few cleanup items. The core approach is sound.
Note: The PR description still references the localFallback: true configuration that has been removed — consider updating it to reflect the current automatic fallback design.
When remoteBuild is true and localFallback is true in azure.yaml, azd automatically falls back to a local Docker build if the remote ACR build fails. Displays a WARNING message when fallback triggers. This helps users on subscriptions that don't support ACR Tasks (e.g., free trial) by gracefully degrading to local Docker builds instead of failing outright. Changes: - Add localFallback field to DockerProjectOptions struct - Add fallback logic in ContainerHelper.Publish() - Update proto definition and generated code - Update azure.yaml JSON schema (service-level and docker-level) - Add mapper registry mappings - Add unit test for fallback behavior Fixes #4618 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Include original error in fallback warning message - Fix proto field ordering (local_fallback after build_args) - Align struct tag spacing for LocalFallback - Remove service-level localFallback from schema (only docker-level) - Fix lint: break long test line under 125 chars Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove the localFallback field from DockerProjectOptions and make fallback-to-local the default behavior when remoteBuild is true and the remote build fails. Before attempting the local build, azd now checks if Docker or Podman is installed and running via CheckInstalled, providing a clear error if neither is available. Changes: - Remove LocalFallback from DockerProjectOptions struct, proto, schema - Always fall back to local build on remote build failure - Validate Docker/Podman availability before local fallback - Reserve proto field number 10 to prevent reuse - Update remoteBuild schema description to document fallback behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Use %w instead of %s for dockerErr in container_helper.go (errorlint) - Fix struct field alignment in DockerProjectOptions (gofmt) - Fix struct literal alignment in mapper_registry.go (gofmt) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1f8fc99 to
4a59e5b
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
* feat: add localFallback option for Docker remote build When remoteBuild is true and localFallback is true in azure.yaml, azd automatically falls back to a local Docker build if the remote ACR build fails. Displays a WARNING message when fallback triggers. This helps users on subscriptions that don't support ACR Tasks (e.g., free trial) by gracefully degrading to local Docker builds instead of failing outright. Changes: - Add localFallback field to DockerProjectOptions struct - Add fallback logic in ContainerHelper.Publish() - Update proto definition and generated code - Update azure.yaml JSON schema (service-level and docker-level) - Add mapper registry mappings - Add unit test for fallback behavior Fixes Azure#4618 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * address PR review feedback - Include original error in fallback warning message - Fix proto field ordering (local_fallback after build_args) - Align struct tag spacing for LocalFallback - Remove service-level localFallback from schema (only docker-level) - Fix lint: break long test line under 125 chars Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: retrigger pipeline checks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: retrigger Windows build check Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * refactor: make local fallback the default when remoteBuild fails Remove the localFallback field from DockerProjectOptions and make fallback-to-local the default behavior when remoteBuild is true and the remote build fails. Before attempting the local build, azd now checks if Docker or Podman is installed and running via CheckInstalled, providing a clear error if neither is available. Changes: - Remove LocalFallback from DockerProjectOptions struct, proto, schema - Always fall back to local build on remote build failure - Validate Docker/Podman availability before local fallback - Reserve proto field number 10 to prevent reuse - Update remoteBuild schema description to document fallback behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: resolve lint errors (errorlint, gofmt) - Use %w instead of %s for dockerErr in container_helper.go (errorlint) - Fix struct field alignment in DockerProjectOptions (gofmt) - Fix struct literal alignment in mapper_registry.go (gofmt) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: correct gofmt struct field alignment after rebase Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: add localFallback option for Docker remote build When remoteBuild is true and localFallback is true in azure.yaml, azd automatically falls back to a local Docker build if the remote ACR build fails. Displays a WARNING message when fallback triggers. This helps users on subscriptions that don't support ACR Tasks (e.g., free trial) by gracefully degrading to local Docker builds instead of failing outright. Changes: - Add localFallback field to DockerProjectOptions struct - Add fallback logic in ContainerHelper.Publish() - Update proto definition and generated code - Update azure.yaml JSON schema (service-level and docker-level) - Add mapper registry mappings - Add unit test for fallback behavior Fixes Azure#4618 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * address PR review feedback - Include original error in fallback warning message - Fix proto field ordering (local_fallback after build_args) - Align struct tag spacing for LocalFallback - Remove service-level localFallback from schema (only docker-level) - Fix lint: break long test line under 125 chars Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: retrigger pipeline checks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: retrigger Windows build check Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * refactor: make local fallback the default when remoteBuild fails Remove the localFallback field from DockerProjectOptions and make fallback-to-local the default behavior when remoteBuild is true and the remote build fails. Before attempting the local build, azd now checks if Docker or Podman is installed and running via CheckInstalled, providing a clear error if neither is available. Changes: - Remove LocalFallback from DockerProjectOptions struct, proto, schema - Always fall back to local build on remote build failure - Validate Docker/Podman availability before local fallback - Reserve proto field number 10 to prevent reuse - Update remoteBuild schema description to document fallback behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: resolve lint errors (errorlint, gofmt) - Use %w instead of %s for dockerErr in container_helper.go (errorlint) - Fix struct field alignment in DockerProjectOptions (gofmt) - Fix struct literal alignment in mapper_registry.go (gofmt) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: correct gofmt struct field alignment after rebase Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: add localFallback option for Docker remote build When remoteBuild is true and localFallback is true in azure.yaml, azd automatically falls back to a local Docker build if the remote ACR build fails. Displays a WARNING message when fallback triggers. This helps users on subscriptions that don't support ACR Tasks (e.g., free trial) by gracefully degrading to local Docker builds instead of failing outright. Changes: - Add localFallback field to DockerProjectOptions struct - Add fallback logic in ContainerHelper.Publish() - Update proto definition and generated code - Update azure.yaml JSON schema (service-level and docker-level) - Add mapper registry mappings - Add unit test for fallback behavior Fixes Azure#4618 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * address PR review feedback - Include original error in fallback warning message - Fix proto field ordering (local_fallback after build_args) - Align struct tag spacing for LocalFallback - Remove service-level localFallback from schema (only docker-level) - Fix lint: break long test line under 125 chars Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: retrigger pipeline checks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: retrigger Windows build check Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * refactor: make local fallback the default when remoteBuild fails Remove the localFallback field from DockerProjectOptions and make fallback-to-local the default behavior when remoteBuild is true and the remote build fails. Before attempting the local build, azd now checks if Docker or Podman is installed and running via CheckInstalled, providing a clear error if neither is available. Changes: - Remove LocalFallback from DockerProjectOptions struct, proto, schema - Always fall back to local build on remote build failure - Validate Docker/Podman availability before local fallback - Reserve proto field number 10 to prevent reuse - Update remoteBuild schema description to document fallback behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: resolve lint errors (errorlint, gofmt) - Use %w instead of %s for dockerErr in container_helper.go (errorlint) - Fix struct field alignment in DockerProjectOptions (gofmt) - Fix struct literal alignment in mapper_registry.go (gofmt) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: correct gofmt struct field alignment after rebase Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: add localFallback option for Docker remote build When remoteBuild is true and localFallback is true in azure.yaml, azd automatically falls back to a local Docker build if the remote ACR build fails. Displays a WARNING message when fallback triggers. This helps users on subscriptions that don't support ACR Tasks (e.g., free trial) by gracefully degrading to local Docker builds instead of failing outright. Changes: - Add localFallback field to DockerProjectOptions struct - Add fallback logic in ContainerHelper.Publish() - Update proto definition and generated code - Update azure.yaml JSON schema (service-level and docker-level) - Add mapper registry mappings - Add unit test for fallback behavior Fixes Azure#4618 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * address PR review feedback - Include original error in fallback warning message - Fix proto field ordering (local_fallback after build_args) - Align struct tag spacing for LocalFallback - Remove service-level localFallback from schema (only docker-level) - Fix lint: break long test line under 125 chars Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: retrigger pipeline checks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: retrigger Windows build check Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * refactor: make local fallback the default when remoteBuild fails Remove the localFallback field from DockerProjectOptions and make fallback-to-local the default behavior when remoteBuild is true and the remote build fails. Before attempting the local build, azd now checks if Docker or Podman is installed and running via CheckInstalled, providing a clear error if neither is available. Changes: - Remove LocalFallback from DockerProjectOptions struct, proto, schema - Always fall back to local build on remote build failure - Validate Docker/Podman availability before local fallback - Reserve proto field number 10 to prevent reuse - Update remoteBuild schema description to document fallback behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: resolve lint errors (errorlint, gofmt) - Use %w instead of %s for dockerErr in container_helper.go (errorlint) - Fix struct field alignment in DockerProjectOptions (gofmt) - Fix struct literal alignment in mapper_registry.go (gofmt) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: correct gofmt struct field alignment after rebase Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: add localFallback option for Docker remote build When remoteBuild is true and localFallback is true in azure.yaml, azd automatically falls back to a local Docker build if the remote ACR build fails. Displays a WARNING message when fallback triggers. This helps users on subscriptions that don't support ACR Tasks (e.g., free trial) by gracefully degrading to local Docker builds instead of failing outright. Changes: - Add localFallback field to DockerProjectOptions struct - Add fallback logic in ContainerHelper.Publish() - Update proto definition and generated code - Update azure.yaml JSON schema (service-level and docker-level) - Add mapper registry mappings - Add unit test for fallback behavior Fixes Azure#4618 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * address PR review feedback - Include original error in fallback warning message - Fix proto field ordering (local_fallback after build_args) - Align struct tag spacing for LocalFallback - Remove service-level localFallback from schema (only docker-level) - Fix lint: break long test line under 125 chars Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: retrigger pipeline checks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: retrigger Windows build check Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * refactor: make local fallback the default when remoteBuild fails Remove the localFallback field from DockerProjectOptions and make fallback-to-local the default behavior when remoteBuild is true and the remote build fails. Before attempting the local build, azd now checks if Docker or Podman is installed and running via CheckInstalled, providing a clear error if neither is available. Changes: - Remove LocalFallback from DockerProjectOptions struct, proto, schema - Always fall back to local build on remote build failure - Validate Docker/Podman availability before local fallback - Reserve proto field number 10 to prevent reuse - Update remoteBuild schema description to document fallback behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: resolve lint errors (errorlint, gofmt) - Use %w instead of %s for dockerErr in container_helper.go (errorlint) - Fix struct field alignment in DockerProjectOptions (gofmt) - Fix struct literal alignment in mapper_registry.go (gofmt) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: correct gofmt struct field alignment after rebase Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: add localFallback option for Docker remote build When remoteBuild is true and localFallback is true in azure.yaml, azd automatically falls back to a local Docker build if the remote ACR build fails. Displays a WARNING message when fallback triggers. This helps users on subscriptions that don't support ACR Tasks (e.g., free trial) by gracefully degrading to local Docker builds instead of failing outright. Changes: - Add localFallback field to DockerProjectOptions struct - Add fallback logic in ContainerHelper.Publish() - Update proto definition and generated code - Update azure.yaml JSON schema (service-level and docker-level) - Add mapper registry mappings - Add unit test for fallback behavior Fixes Azure#4618 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * address PR review feedback - Include original error in fallback warning message - Fix proto field ordering (local_fallback after build_args) - Align struct tag spacing for LocalFallback - Remove service-level localFallback from schema (only docker-level) - Fix lint: break long test line under 125 chars Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: retrigger pipeline checks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: retrigger Windows build check Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * refactor: make local fallback the default when remoteBuild fails Remove the localFallback field from DockerProjectOptions and make fallback-to-local the default behavior when remoteBuild is true and the remote build fails. Before attempting the local build, azd now checks if Docker or Podman is installed and running via CheckInstalled, providing a clear error if neither is available. Changes: - Remove LocalFallback from DockerProjectOptions struct, proto, schema - Always fall back to local build on remote build failure - Validate Docker/Podman availability before local fallback - Reserve proto field number 10 to prevent reuse - Update remoteBuild schema description to document fallback behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: resolve lint errors (errorlint, gofmt) - Use %w instead of %s for dockerErr in container_helper.go (errorlint) - Fix struct field alignment in DockerProjectOptions (gofmt) - Fix struct literal alignment in mapper_registry.go (gofmt) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: correct gofmt struct field alignment after rebase Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: add localFallback option for Docker remote build When remoteBuild is true and localFallback is true in azure.yaml, azd automatically falls back to a local Docker build if the remote ACR build fails. Displays a WARNING message when fallback triggers. This helps users on subscriptions that don't support ACR Tasks (e.g., free trial) by gracefully degrading to local Docker builds instead of failing outright. Changes: - Add localFallback field to DockerProjectOptions struct - Add fallback logic in ContainerHelper.Publish() - Update proto definition and generated code - Update azure.yaml JSON schema (service-level and docker-level) - Add mapper registry mappings - Add unit test for fallback behavior Fixes Azure#4618 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * address PR review feedback - Include original error in fallback warning message - Fix proto field ordering (local_fallback after build_args) - Align struct tag spacing for LocalFallback - Remove service-level localFallback from schema (only docker-level) - Fix lint: break long test line under 125 chars Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: retrigger pipeline checks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: retrigger Windows build check Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * refactor: make local fallback the default when remoteBuild fails Remove the localFallback field from DockerProjectOptions and make fallback-to-local the default behavior when remoteBuild is true and the remote build fails. Before attempting the local build, azd now checks if Docker or Podman is installed and running via CheckInstalled, providing a clear error if neither is available. Changes: - Remove LocalFallback from DockerProjectOptions struct, proto, schema - Always fall back to local build on remote build failure - Validate Docker/Podman availability before local fallback - Reserve proto field number 10 to prevent reuse - Update remoteBuild schema description to document fallback behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: resolve lint errors (errorlint, gofmt) - Use %w instead of %s for dockerErr in container_helper.go (errorlint) - Fix struct field alignment in DockerProjectOptions (gofmt) - Fix struct literal alignment in mapper_registry.go (gofmt) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: correct gofmt struct field alignment after rebase Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Problem
azd deployfails for users on free trial subscriptions whenremoteBuild: trueis set in azure.yaml, because ACR Tasks are not available on free trial SKUs. Users must manually remove theremoteBuildline to work around this (#4618).Solution
Add a new
localFallbackboolean field to Docker service configuration in azure.yaml:When
remoteBuild: trueandlocalFallback: true, if the remote ACR build fails for any reason, azd automatically retries with a local Docker build and displays a warning:Changes
pkg/project/framework_service_docker.goLocalFallbackfield toDockerProjectOptionspkg/project/container_helper.goPublish()withux.WarningMessagepkg/project/mapper_registry.goLocalFallbackin proto conversions (3 locations)grpc/proto/models.protolocal_fallbackfield to proto messagepkg/azdext/models.pb.goschemas/v1.0/azure.yaml.jsonlocalFallbackto schema (service-level and docker-level)pkg/project/container_helper_test.goDesign Decisions
remoteBuildto a string enum ("prefer"): A separate field is lower risk — doesn't change existingremoteBuildtype or semanticsux.WarningMessagematching existing azd warning patternsFixes #4618