In the previous post ( Create Azure Container Registry Part1) we have discussed how to create an Azure container registry through the Azure portal.This post explains how to create an Azure container registry using Azure CLI(Command Line Interface). Azure CLI is a tool that provide great support to manage Azure resources. Let’s look at the steps.
- Install the Azure CLI.You can find the installation details from here.( https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest)
- After installation completed, open windows PowerShell and type az login command to login to your Azure subscription.
- A browser window will prompt for you to login. Enter your Azure subscription credentials and login.
- After login succeed , list of all the subscriptions which you have access will be displayed in the PowerShell window.
Now you can execute an Azure CLI command to create a container registry by providing required parameters.
Following are the required parameters.
-n name of the container registry
-g name of the resource group
--sku store keeping unit of the container registry
Following image shows how to create a container registry named mydemoacr inside resource group named myresgroup
If container registry created without any issues you will get a message similar to shown in the image below.
The container registry creation command az acr create may fail with the following error message which says resource group could not be found.This failure may occurred when you have more than one subscription and you have tried to execute the Azure CLI command as explained above.The reason for this issue is you are trying to create a container registry in one Azure subscription by providing name of the resource group which is located inside a different subscription belongs to the same account.
To solve this issue, you have to use subscription id parameter with the container registry creation command. Then you can provide the subscription id which you need to create the container registry which is having the resource group you are specifying. Following is the syntax for the command to be used along with subscription id
Command : az acr create –n mydemoacr –g myresgroup –sku Basic –subscription my subscription id
After you get container registry creation succeed message as shown in the above image, go to Azure portal and search for mydemoacr. You can find the name of the container registry among search results.
click on the searched result to open the container registry.
So far you have learned how to create a container registry by executing Azure CLI commands with mandatory parameters. You can create another container registry by providing mandatory and optional parameters.
following are the optional parameters
--admin-enabled indicate whether admin user is enabled or disabled by providing true or false as value
--location provide the geo location
--subscription name or id of subscription
Command : az acr create -n mydemoacr2 -g myresgroup --sku Basic --admin-enabled true --location eastus --subscription mysubscription id
In this post we have explored how to create a container registry quickly and easily using Azure CLI Command.
Steps are nicely elaborated. Great resource for a beginner.
ReplyDelete