0

I am working on a script where I want to run az acr import. The command tries to list the repository but fails with the error: The resource with name 'name' and type 'Microsoft.ContainerRegistry/registries' could not be found in subscription

As you can see in the screenshot below. This registry is indeed present in the subscription. I am able to login, run docker push as well which completes successfully. But az acr show returns a failure.

enter image description here

  • Is the container registry part of the same subscription in the error code? Looks like while you're using az login > you are not logged into the subscription that has your container registry deployed. Try az account set --subscription subscription_id and then try az account set --subscription subscription_id Reference :- https://stackoverflow.com/questions/55760167/az-acr-unable-to-find-repository-in-case-of-multiple-subscription-on-single-ac – SiddheshDesai Mar 10 '23 at 13:55
  • Yes it is part of same subscription. I azure az acr login to see if that helps somehow. But that doesn't help. – Susheel Bhatt Mar 10 '23 at 14:28

1 Answers1

0

I tried to log in to another Azure subscription and tried running

az acr show -n <acr-name> 

and received same error code as yours even when the az acr log in command was successfull, refer below:-

enter image description here

When I ran the same commands and logged into the correct subscription where my ACR is deployed, Then I was able to retrieve acr details with az acr show -n <acr-name> command, Refer below:-

I am using sudo before every Azure CLI command to make sure I am running the scripts as a root user.

Scripts:-

Logged into my Azure account:-

sudo az login

Checked if the account is set to the correct subscription as my ACR:-

sudo az account set --subscription <subscription-id>

Logged into ACR:-

sudo az acr login --name <acr-name> --username siliconacr --password <password>

Ran the command:-

sudo az acr show --name siliconacr

Make sure you only add Container registry name and not the log in server name in the az acr show - n command.

Output:-

enter image description here

enter image description here

If the issue persists try az logout command let and try logging in again as your Azure CLI in the ubuntu VM might have cached the credentials.

Reference:-

azure - az acr - Unable to find repository in case of multiple subscription on single account - Stack Overflow

SiddheshDesai
  • 3,668
  • 1
  • 2
  • 11
  • I tried all this already which didn't help. I eventully uninstalled my az cli and cleared all the azure folders. But it still didn't help. Suprisingly I can see all the container registries using cloud shell or any other machine. – Susheel Bhatt Mar 10 '23 at 14:58
  • Are the container registries visible now? Or are they visible in another machines and not the current one? – SiddheshDesai Mar 10 '23 at 15:00
  • Did you install az cli by this method and not curl in your linux machine - https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt#option-2-step-by-step-installation-instructions – SiddheshDesai Mar 10 '23 at 15:04
  • Also, Try az account clear command to clear azure cli's local cache and then try to log in again with correct subscription id. Reference - https://learn.microsoft.com/en-us/cli/azure/account?view=azure-cli-latest#az-account-clear and az logout is used to clear current subscription. – SiddheshDesai Mar 10 '23 at 15:06
  • Refer - https://i.imgur.com/E7uPwO6.png – SiddheshDesai Mar 10 '23 at 15:12