ACR Azure PowerShell Connect-AzAccount Containers Docker docker login docker push docker run docker tag Get-AzContainerRegistry Get-AzContainerRegistryCredential Get-AzSubscription Microsoft Microsoft Azure New-AzContainerRegistry Select-AzSubscription Test-AzContainerRegistryNameAvailability Update-AzContainerRegistry Update-AzContainerRegistryCredential
This is the first post in a series of articles where I will show you how to manage an Azure Container Registry (ACR) with Azure PowerShell. In this first post, I want to show you how to create an ACR and use basic Docker commands with your ACR.
The Azure Container Registry (ACR) is a managed Docker registry service based on the open source Docker Registry. Using an ACR is useful for controlling where your images are stored and keeping them close to the application infrastructure.
This tutorial assumes that you already have a Microsoft Azure account configured.
You created a Resource Group for these resources, and the new ones deployed in this tutorial will join that group. If you want to know how to create a Resource Group, check out this
link.
You must also have Docker installed locally. If you want to know how to install Docker on the Windows server, check out this
link.
If you want to know how to install the PowerShell Azure module on your machine, check out this
link. The simplest way to get started is to sign in interactively at the command line.
Connect-AzAccount
This cmdlet will bring up a dialog box prompting you for your email address and password associated with your Azure account. If you have more than one subscription associated with your mail account, you can choose the default subscription. To perform this task, we will use the following commands:
Before creating an ACR, you must first verify the availability of the desired container registry name. As this will be part of the URL (.azurecr.io) to access the service, it must be unique. To check availability, use the Test-AzContainerRegistryNameAvailability cmdlet with the following syntax.
If you need to change your ACR settings, you should use the Update-AzContainerRegistry cmdlet as shown below. The following example changes the SKU of an ACR.
When creating an ACR instance, we have a user (the name of the ACR) and two passwords generated at creation. To obtain the credentials, you must use the Get-AzContainerRegistryCredential cmdlet with the following syntax.
Suppose you want to generate new passwords, either because they are compromised or simply want to change them. You can perform this operation using the Update-AzContainerRegistryCredential cmdlet with the following syntax.
The method used in this demo to log in to the ACR instance is through the username and password. It is recommended to use an individual identity or a service principal for access to the ACR in production scenarios.
To push an image to an Azure container registry and not the central Docker registry, you must tag it with the registry hostname. In this example, I use an image from Nginx, and my (ACR) server name is: acrdemowe.azurecr.io