Setting a default Azure Container Registry name

Tired of typing the registry name every time you run az acr? So was I.

The more I used az acr the more I wanted a way of setting the --name to a default  value so I did not have to keep typing it. Turns out there is a way, you just have to dig for it.

To set the default registry use az configure --defaults acr=<registry name>.

For completeness, what this does is modify the ~/.azure/config file. In Windows, ~ would be the user profile path, for example, c:\users\edward. It adds a [default] section if it does not already exist and then sets acr to the registry name specified.

An example of a complete config file would be like this:

[cloud]
name = AzureCloud

[core]
first_run = yes

[defaults]
acr = crexample

Conclusion

Now I can save some time by not needing to add --name to every az acr command, finally. Hopefully it helps you as well. I just wish it was a little more well documented when you do a --help on the command line.

az acr repository
azure-cli/_params.py at f70a427035f4577c817942968183d475a415bcb2 · Azure/azure-cli
Azure Command-Line Interface. Contribute to Azure/azure-cli development by creating an account on GitHub.