Skip to main content
Jorge Bernhardt Jorge Bernhardt
  1. Posts/

Azure Container Registry (ACR) - Part 2

·529 words·3 mins· 100 views · 5 likes ·
ACR Azure PowerShell Connect-AzAccount Containers

As I mentioned in my previous post today, I want to show you how to enable the geo-replication of your ACR. This feature will allow us to manage a single registry across all regions, push images to a single registry while the Azure service manages the replication, and last but not least, allows us to keep images very close to the application infrastructure.

Prerequisites>

Prerequisites #

  • This tutorial assumes that you already have a Microsoft Azure account configured.
  • You already have an Azure Container Registry (ACR) and are properly configured. If you want to know how to create it, see this link.
Azure PowerShell Workaround>

Azure PowerShell Workaround #

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:

Get-AzSubscription
Select-AzSubscription -Subscription "My Subscription"

Once you set your default subscription, you’re ready to start.

Set the variables>

Set the variables #

Here, we define the characteristics of our environment and the resource’s properties.

$resourceGroupName = 'RG-DEMO-WE'
$azcRegName = 'acrdemowe'
$replicaName = 'AcRegDemoNE'
$replicaLocation = 'northeurope'
Geo-replication in ACR>

Geo-replication in ACR #

Please note that Geographic Replication is a feature of Premium records only. Geographic replication will allow you to manage a single ACR that will serve multiple regions, among other interesting features. if you don’t know if your ACR is premium, you can check it using the following command

Get-AzContainerRegistry `
    -Name $azcRegName `
    -ResourceGroupName $resourceGroupName `
    -IncludeDetail

Get-AzContainerRegistry
If your ACR is not yet Premium, you can change it using the following command.

Update-AzContainerRegistry `
    -Name $azcRegName `
    -ResourceGroupName $resourceGroupName `
    -Sku Premium
Update-AzContainerRegistry
>

Update-AzContainerRegistry
#

Creates a container registry replication>

Creates a container registry replication #

To create a new container registry replication, use the New-AzContainerRegistryReplication cmdlet with the following syntax.

New-AzContainerRegistryReplication `
    -Name $replicaName `
    -ResourceGroupName $resourceGroupName `
    -RegistryName $azcRegName `
    -Location $replicaLocation `
    -Tag @{Environment="DEMO"}

As you can see, you should refer to the Master ACR in the -RegistryName parameter, specify a name for the new ACR and select the zone where the new replica will be hosted.

New-AzContainerRegistryReplication

Gets the status of the replication>

Gets the status of the replication #

To get information about the status of replication, use the Get-AzContainerRegistryReplication cmdlet with the following syntax.

Get-AzContainerRegistryReplication `
    -Name $replicaName `
    -ResourceGroupName $resourceGroupName `
    -RegistryName $azcRegName `
    | Format-List
Get-AzContainerRegistryReplication
>

Get-AzContainerRegistryReplication
#

ACR Geo-Replication
>

ACR Geo-Replication
#

Removes a container registry replication>

Removes a container registry replication #

finally, to remove a container registry replication, you should use the Remove-AzContainerRegistryReplication cmdlet as shown below.

Remove-AzContainerRegistryReplication `
    -Name $replicaName `
    -ResourceGroupName $resourceGroupName `
    -RegistryName $azcRegName

In the next post, I will show you how to use Azure Container Registry webhooks. Thanks for reading my post. I hope you find it useful. If you want to know more about Azure Container Registry, check out this link: https://docs.microsoft.com/en-us/azure/container-registry/