azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

az acr build doesn't support new ACR with ABAC and a suffix in its login server name

Open xi4n opened this issue 8 months ago • 1 comments

Describe the bug

First of all the whole documentation in general of az acr is not very clear about the new ACRs with a system assigned random suffix in its login server name. For instance, as a user, let's say my ACR name is myacr, the login server is myacr-randomsuffix.azurecr.io, why I as a user can log in with az acr login --name myacr, but a GitHub service principal cannot (it gets "The resource with name 'XXXXX' and type 'Microsoft.ContainerRegistry/registries' could not be found in subscription 'XXXXXXX'"), so that it muse use az acr login --name myacr --suffix randomsuffix to succeed. Which is fine for me.

However, in az acr build this problem comes again. There, there's even no parameter --suffix and without which, the command in GitHub workflow will fail (similar error message).

What should we do here?

Related command

az acr build -r myacr -t myimage . -- wrong
az acr build -r myacr-randomsuffix -t myimage . -- wrong
az acr build -r myacr-randomsuffix.azurecr.io -t myimage . -- wrong again.
So where's the equivalent command to az acr login, with --suffix?

Errors

"The resource with name 'myacr' and type 'Microsoft.ContainerRegistry/registries' could not be found in subscription 'XXXXXXX'"

Issue script & Debug output

See above

Expected behavior

That whether there's a parameter --suffix in az acr build, or, to make it work by omitting the suffix (I still don't see why there's the difference between a human user (which doesn't need to add --suffix in az acr login and a service principal, which needs it)).

Environment Summary

Not really relevant, it's the GitHub Workflow Ubuntu 22.04 or 24.04.

Additional context

No response

xi4n avatar Jun 05 '25 19:06 xi4n

route to acr team

yonzhan avatar Jun 05 '25 22:06 yonzhan

@johnsonshi @leodewang could you please look into this issue? thanks

FeynmanZhou avatar Jul 25 '25 18:07 FeynmanZhou

We're looking into it.

johnsonshi avatar Jul 25 '25 20:07 johnsonshi

@xi4n are you using the latest version? Our engineers tried to repro it in the latest version and everything worked fine.

az acr build --registry dnlregistryname --image helloacrtasks:v1 --file Dockerfile .

az acr build --registry dddddddddddd-adfvbqhmd2b4g6dg.azurecr.io --image hello-world --file Dockerfile .

Both worked fine. Can you confirm your CLI version?

johnsonshi avatar Jul 26 '25 00:07 johnsonshi

@lizMSFT are you able to take a look and help?

johnsonshi avatar Nov 06 '25 11:11 johnsonshi

@xi4n The error indicates that the resource cannot be found in the specified subscription. Please try again using the --resource-group <rg> parameter, for example: az acr build -r myacr --resource-group myrg -t myimage .

lizMSFT avatar Nov 11 '25 13:11 lizMSFT

@xi4n as the issue is most likely an issue with missing --resource-group parameter, please try again on your side. If the issue persists, please feel free to reopen this issue.

johnsonshi avatar Nov 17 '25 02:11 johnsonshi