Skip to content

az acr build fails when using --build-arg, but works without it #31071

@hamzaadevops

Description

@hamzaadevops

Describe the bug

I am using az acr build in a GitHub Actions workflow to build and push a Docker image to Azure Container Registry (ACR).

The following command works fine:

az acr build --image ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} \
  --registry ${{ env.AZURE_CONTAINER_REGISTRY }} \
  -g ${{ env.ACR_RESOURCE_GROUP }} \
  -f ${{ env.DOCKER_FILE }} \
  ${{ env.BUILD_CONTEXT_PATH }}

Related command

But this command gives us the error as shown in the screenshot

az acr build --image ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} \
  --registry ${{ env.AZURE_CONTAINER_REGISTRY }} \
  -g ${{ env.ACR_RESOURCE_GROUP }} \
  -f ${{ env.DOCKER_FILE }} \
  --build-arg AZURE_COMMUNICATION_SERVICES_CONNECTION_STRING=${{ secrets.AZURE_COMMUNICATION_SERVICES_CONNECTION_STRING }} \
  --build-arg AZURE_COMMUNICATION_SENDER_EMAIL=${{ secrets.AZURE_COMMUNICATION_SENDER_EMAIL }} \
  --build-arg AZURE_COMMUNICATION_RECIPIENT_EMAIL=${{ secrets.AZURE_COMMUNICATION_RECIPIENT_EMAIL }} \
  ${{ env.BUILD_CONTEXT_PATH }}

Image

Errors

However, when I add --build-arg options, the command fails with the error:
"the following arguments are required: <SOURCE_LOCATION>"

Expected behavior

Both versions of the command should work as expected. Adding --build-arg should not break the az acr build command.

Actual Behavior:
Adding --build-arg results in the following error:
ERROR: the following arguments are required: <SOURCE_LOCATION>

Additional context

I confirmed that the Dockerfile and build context exist
The same command works locally, but fails in GitHub Actions
Possible issue with how az acr build handles --build-arg in GitHub Actions?

Metadata

Metadata

Assignees

Labels

Auto-AssignAuto assign by botContainer Registryaz acrPossible-SolutionService AttentionThis issue is responsible by Azure service team.Similar-IssuebugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions