I'm using Azure CLI v2.0.62.
I do have multiple subscriptions - S1, S2, S3, S4 - in Azure on the single account.
I'm executing below script to insert dynamic value into repository:
az login
az acr build "ParentStorage" --platform windows -f Dockerfile -t ChildRepository:<dynamicValue>
Here, ParentStorage
is of Storage Account
type and ChileRepository
is of Repository
type.
At first, when login command gets executed, it gives me list of available subscription. But after executing az acr build...
command it is throwing error message as below:
Error
The resource with name 'ParentStorage' and type 'Microsoft.ContainerRegistry/registries' could not be found in subscription 'Visual Studio Professional (ID)'.
What I have found till now is, it is trying to search under my Visual Studio subscription (S1
). As S1
was the default subscription and repository was in S2
. So I set S2
as default subscription and tried again but it didn't work.
Event when I tried to execute below command, it threw the same error:
az acr show --name ParentStorage
P.S.: I tried to login with specific subscription but unable to do so.
Please let me know what is I'm missing here.
For your issue, it seems your registry is not in the current subscription. When you use the CLI command az login
then you log in with a default subscription. For you, it seems the "Visual Studio Professional (ID)" is the default. You should check if your registry is in the current subscription. If not, you should set that subscription as the current subscription through the CLI command:
az account set --subscription subscription_id
Then I suggest you'd better check if the registry exists again with the CLI command:
az acr show -n acr_name
It will show the information of your registry. This time, you can build the image with the CLI command az acr build
as you want.
Also, you can set the subscription in the login time with the parameter --subscription
through the CLI command az login
.
If you have more questions, please let me know. Or if you think it's helpful you can accept it as the answer.