New features added in the Azure Container Registry PowerShell module

Published 04-13-2021 08:20 AM 1,138 Views
Microsoft

While Azure Container Registry (ACR) is prevalent as an Azure service, the corresponding Az.ContainerRegistry Azure PowerShell module wasn’t fully featured. Sometimes, PowerShell users had to take advantage of the Az CLI. We want to allow PowerShell user to be able to fully manage container images. Starting with Az.ContainerRegistry version 2.2.1, we will gradually be rolling out new cmdlets and new parameters. In this release, you can now fully manage (Get-, Remove-, Update-) repositories, manifests, and tags with increased performance.

 

ACR overview

The graph below shows resources and the structure under an Azure container registry. We’ll dive into more details later in this article.

YaboHu_0-1617936659735.png

 

Authentication

 
 

After login into your Azure account in Azure-PowerShell with

 

PS:> Connect-AzAccount

 

You can now simply run

 

PS:> Connect-AzContainerRegistry -Name $RegistryName

 

Alternatively, you can also use service principal authentication

 

PS:> Connect-AzContainerRegistry -Name $RegistryName -UserName $ApplicationId -Password $ClientSecret

 

If you happened to have the registry admin user enabled

 

PS:> $secret = Get-AzContainerRegistryCredential -ResourceGroupName $RGName -Name $RegistryName
PS:> Connect-AzContainerRegistry -Name $RegistryName 
-UserName $secret.UserName 
-Password $secret.Password

 

 

Repositories

A repository is a collection of container images or other artifacts in a registry that have the same name, but different tags. For example, the following three images are in the acr-helloworld repository:

  • acr-helloworld:latest
  • acr-helloworld:v1
  • acr-helloworld:v2

 

A JSON format repository could look like the following

 

{
  "registry": "xxx.azurecr.io",
  "imageName": "test/busybox",
  "createdTime": "2021-02-02T04:11:14.4504049Z",
  "lastUpdateTime": "2021-02-02T05:02:14.2671834Z",
  "manifestCount": 1,
  "tagCount": 150,
  "changeableAttributes": {
    "deleteEnabled": true,
    "writeEnabled": true,
    "readEnabled": true,
    "listEnabled": true
  }

 

To get repositories via Az.ContainerRegistry

 

PS:> $repository = Get-AzContainerRegistryRepository -RegistryName xxx -Name test/busybox

PS:> $repository
Registry             : xxx.azurecr.io
ImageName            : test/busybox
CreatedTime          : 2021-02-02T04:11:14.4504049Z
LastUpdateTime       : 2021-02-02T05:02:14.2671834Z
ManifestCount        : 1
TagCount             : 150
ChangeableAttributes : Microsoft.Azure.Commands.ContainerRegistry.Models.PSChangeableAttribute

PS:> $repository.ChangeableAttributes | ft
DeleteEnabled WriteEnabled ListEnabled ReadEnabled
-------------          ------------          -----------      -----------
         True               True                 True            True

 

You can also list all repository names under your registry

 

PS:> Get-AzContainerRegistryRepository -RegistryName xxx
alpine
test/busybox
test/busybox1
test/busybox10
test/busybox11
test/busybox12

 

To delete an existing repository

 

PS:> Update-AzContainerRegistryRepository -RegistryName xxx -Name test/busybox -DeleteEnabled $true
PS:> Remove- AzContainerRegistryRepository -RegistryName xxx -Name test/busybox

 

 

Images

Grouped in a repository, each image or artifact is a read-only multi-layer snapshot of a Docker-compatible container.

An artifact can be represented as either one of

  • manifest
  • $repository_name:$tag

Manifest

Each image or other artifact pushed to a registry is associated with a JSON format manifest. The manifest, generated by the registry when the content is pushed, uniquely identifies the artifact.

 

"manifests": [
    {
      "digest": "sha256:31a54a0cf86d7354788a8265f60ae6acb4b348a67efbcf7c1007dd3cf7af05ab",
      "imageSize": 764633,
      "createdTime": "2020-12-11T09:17:20.4959715Z",
      "lastUpdateTime": "2020-12-11T09:17:20.4959715Z",
      "architecture": "amd64",
      "os": "linux",
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "configMediaType": "application/vnd.docker.container.image.v1+json",
      "tags": [
        "latest"
      ],
      "changeableAttributes": {
        "deleteEnabled": false,
        "writeEnabled": true,
        "readEnabled": true,
        "listEnabled": true
      }
    }

 

Manifests are identified by a unique SHA-256 hash, manifest digest. Each image or artifact, whether tagged or not, is identified by its digest. The digest value is unique even if the artifact's layer data is identical to that of another artifact. This mechanism is what allows you to repeatedly push identically tagged images to a registry. For example, you can repeatedly push “myimage:latest” to your registry without error because each image is identified by its unique digest.

 

Similarly, to get, list, update, or remove a manifest under a repository

 

PS:> Get-AzContainerRegistryManifest -RegistryName xxx 
-RepositoryName test/busybox50 
-Name sha256:31a54a0cf86d7354788a8265f60ae6acb4b348a67efbcf7c1007dd3cf7af05ab
Registry   : xxx.azurecr.io
ImageName  : test/busybox50
Attributes : Microsoft.Azure.Commands.ContainerRegistry.Models.PSManifestAttributeBase

PS:> Get-AzContainerRegistryManifest -RegistryName xxx -RepositoryName test/busybox50 

PS:> Update-AzContainerRegistryManifest -RegistryName xxx 
-RepositoryName test/busybox50 
-Manifest sha256:31a54a0cf86d7354788a8265f60ae6acb4b348a67efbcf7c1007dd3cf7af05ab
-DeleteEnabled $true

PS:> Remove-AzContainerRegistryManifest -RegistryName xxx 
-RepositoryName test/busybox50 
-Manifest sha256:31a54a0cf86d7354788a8265f60ae6acb4b348a67efbcf7c1007dd3cf7af05ab

 

Please be aware that to delete a repository, all manifests under it should have

 

"deleteEnabled": true

 

 

Tag

Tags for an image or other artifact specifies its version. A single artifact within a repository can be assigned one or many tags, this artifact may also be "untagged." That is, you can delete all tags from an image, while the image's data (its layers) remain in the registry.

 

"tag": {
    "name": "latest",
    "digest": "sha256:31a54a0cf86d7354788a8265f60ae6acb4b348a67efbcf7c1007dd3cf7af05ab",
    "createdTime": "2020-12-11T09:17:20.6865195Z",
    "lastUpdateTime": "2020-12-11T09:17:20.6865195Z",
    "signed": false,
    "changeableAttributes": {
      "deleteEnabled": true,
      "writeEnabled": true,
      "readEnabled": true,
      "listEnabled": true
    }
  }

 

The repository plus a tag defines an image name. You can push and pull an image by specifying its name in the push or pull operation. The tag latest is used by default if you don't provide one in your Docker commands. As you can see in the ACR Overview section, “repository3:latest” and “repository3:v2” both represent the same image “artifact3”.

 

Similarly, to get, list, update,  or remove a tag for one artifact

 

PS:> Get-AzContainerRegistryTag -RegistryName xxx 
-RepositoryName test/busybox50 
-Name latest
Registry   : xxx.azurecr.io
ImageName  : test/busybox50
Attributes : Microsoft.Azure.Commands.ContainerRegistry.Models.PSTagAttributeBase

PS:> Get-AzContainerRegistryTag -RegistryName xxx -RepositoryName test/busybox50 

PS:> Update-AzContainerRegistryTag -RegistryName xxx 
-RepositoryName test/busybox50 
-Name latest
-DeleteEnabled $true

 

Notice that after

 

PS:> Remove-AzContainerRegistryTag -RegistryName xxx 
-RepositoryName test/busybox50 
-Name latest

 

The tag “latest” was removed (untagged), means you cannot find

“test/busybox50:latest”. In this repository anymore, but the corresponding artifact remained (get manifest)

 

PS:> $digest = (Get-AzContainerRegistryTag -RegistryName xxx 
-RepositoryName test/busybox50 
-Name latest). Attributes.Digest

PS:> Get-AzContainerRegistryManifest -RegistryName xxx 
-RepositoryName test/busybox50 
-Name $digest
Registry   : xxx.azurecr.io
ImageName  : test/busybox50
Attributes : Microsoft.Azure.Commands.ContainerRegistry.Models.PSManifestAttributeBase

 

 

It’s also possible to update or delete a manifest by tag, it’s easier since it’s more recognizable to use a meaningful tag than series SHA256 hash code

 

PS:> Update-AzContainerRegistryManifest -RegistryName xxx 
-RepositoryName test/busybox50 
-Tag latest
-DeleteEnabled $true

PS:> Remove-AzContainerRegistryManifest -RegistryName xxx 
-RepositoryName test/busybox50 
-Tag latest

 

In this way, not only the tag, but the artifact itself would also be deleted.

 

Performance

We found there are performance issues in each repository, manifest, and tag manipulating operation. They were all relatively slow because ACR categorized each operation with different scopes.

A typical scope is in below format:

 

“$resource_type:$resource_name:$permission”

 

For example, to list all tags under repository “alpine”, the scope for this operation would be

 

“repository:alpine:metadata_read”

 

The specific token required for this request is assigned based on the exact scope.

 

For these kinds of operations, there will be 2 more extra HTTP requests sent out for token exchange before your actual operation.

 

HTTP Method:
POST
Absolute Uri:
https://xxx.azurecr.io/oauth2/token

HTTP Method:
POST
Absolute Uri:
https://xxx.azurecr.io/oauth2/Exchange

 

To reduce these costly requests, we implemented a token cache in your current PowerShell session, it will cache all ACR tokens. For operations that used existing tokens (operations with same scope), the previously referenced token exchange won’t happen until tokens in the cache expire. For repetitive operations, the total number of requests is now only one instead of three.

 

You can clear this token cache in your current PowerShell session by running

 

PS:> Clear-AzContext

 

This cmdlet also terminates the login state for Azure. Remember to re-connect.

 

PS:> Connect-AzAccount

 

 

Conclusion & Feedback

With these features added, Az.ContainerRegistry is now much more usable. It's highly recommended to download the latest module at

https://www.powershellgallery.com/packages?q=az.containerregistry

and give a shot.

 

We also look forward to your feedback. Report issues at:

https://github.com/Azure/azure-powershell/issues

 

Yabo Hu
 Software Engineer
 Azure-PowerShell Team

%3CLINGO-SUB%20id%3D%22lingo-sub-2263008%22%20slang%3D%22en-US%22%3ENew%20features%20added%20in%20the%20Azure%20Container%20Registry%20PowerShell%20module%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2263008%22%20slang%3D%22en-US%22%3E%3CP%3EWhile%20Azure%20Container%20Registry%20(ACR)%20is%20prevalent%20as%20an%20Azure%20service%2C%20the%20corresponding%20Az.ContainerRegistry%20Azure%20PowerShell%20module%20wasn%E2%80%99t%20fully%20featured.%20Sometimes%2C%20PowerShell%20users%20had%20to%20take%20advantage%20of%20the%20Az%20CLI.%20We%20want%20to%20allow%20PowerShell%20user%20to%20be%20able%20to%20fully%20manage%20container%20images.%20Starting%20with%20Az.ContainerRegistry%20version%202.2.1%2C%20we%20will%20gradually%20be%20rolling%20out%20new%20cmdlets%20and%20new%20parameters.%20In%20this%20release%2C%20you%20can%20now%20fully%20manage%20(Get-%2C%20Remove-%2C%20Update-)%20repositories%2C%20manifests%2C%20and%20tags%20with%20increased%20performance.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-1303090150%22%20id%3D%22toc-hId-1302248314%22%3EACR%20overview%3C%2FH1%3E%0A%3CP%3EThe%20graph%20below%20shows%20resources%20and%20the%20structure%20under%20an%20Azure%20container%20registry.%20We%E2%80%99ll%20dive%20into%20more%20details%20later%20in%20this%20article.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22YaboHu_0-1617936659735.png%22%20style%3D%22width%3A%20702px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F271408i3B3ABCB4C1AE65A8%2Fimage-dimensions%2F702x325%3Fv%3Dv2%22%20width%3D%22702%22%20height%3D%22325%22%20role%3D%22button%22%20title%3D%22YaboHu_0-1617936659735.png%22%20alt%3D%22YaboHu_0-1617936659735.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--504364313%22%20id%3D%22toc-hId--505206149%22%3EAuthentication%3C%2FH1%3E%0A%3CDIV%20id%3D%22tinyMceEditorYaboHu_1%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%20id%3D%22tinyMceEditorYaboHu_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3EAfter%20login%20into%20your%20Azure%20account%20in%20Azure-PowerShell%20with%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPS%3A%26gt%3B%20Connect-AzAccount%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20now%20simply%20run%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPS%3A%26gt%3B%20Connect-AzContainerRegistry%20-Name%20%24RegistryName%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlternatively%2C%20you%20can%20also%20use%20service%20principal%20authentication%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPS%3A%26gt%3B%20Connect-AzContainerRegistry%20-Name%20%24RegistryName%20-UserName%20%24ApplicationId%20-Password%20%24ClientSecret%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%26nbsp%3Byou%20happened%20to%20have%20the%20registry%20admin%20user%20enabled%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPS%3A%26gt%3B%20%24secret%20%3D%20Get-AzContainerRegistryCredential%20-ResourceGroupName%20%24RGName%20-Name%20%24RegistryName%0APS%3A%26gt%3B%20Connect-AzContainerRegistry%20-Name%20%24RegistryName%20%0A-UserName%20%24secret.UserName%20%0A-Password%20%24secret.Password%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-1983148520%22%20id%3D%22toc-hId-1982306684%22%3E%26nbsp%3B%3C%2FH1%3E%0A%3CH1%20id%3D%22toc-hId-175694057%22%20id%3D%22toc-hId-174852221%22%3ERepositories%3C%2FH1%3E%0A%3CP%3EA%26nbsp%3Brepository%26nbsp%3Bis%20a%20collection%20of%20container%20images%20or%20other%20artifacts%20in%20a%20registry%20that%20have%20the%20same%20name%2C%20but%20different%20tags.%20For%20example%2C%20the%20following%20three%20images%20are%20in%20the%26nbsp%3Bacr-helloworld%26nbsp%3Brepository%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Eacr-helloworld%3Alatest%3C%2FLI%3E%0A%3CLI%3Eacr-helloworld%3Av1%3C%2FLI%3E%0A%3CLI%3Eacr-helloworld%3Av2%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20JSON%20format%20repository%20could%20look%20like%20the%20following%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%7B%0A%20%20%22registry%22%3A%20%22xxx.azurecr.io%22%2C%0A%20%20%22imageName%22%3A%20%22test%2Fbusybox%22%2C%0A%20%20%22createdTime%22%3A%20%222021-02-02T04%3A11%3A14.4504049Z%22%2C%0A%20%20%22lastUpdateTime%22%3A%20%222021-02-02T05%3A02%3A14.2671834Z%22%2C%0A%20%20%22manifestCount%22%3A%201%2C%0A%20%20%22tagCount%22%3A%20150%2C%0A%20%20%22changeableAttributes%22%3A%20%7B%0A%20%20%20%20%22deleteEnabled%22%3A%20true%2C%0A%20%20%20%20%22writeEnabled%22%3A%20true%2C%0A%20%20%20%20%22readEnabled%22%3A%20true%2C%0A%20%20%20%20%22listEnabled%22%3A%20true%0A%20%20%7D%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20get%20repositories%20via%20Az.ContainerRegistry%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPS%3A%26gt%3B%20%24repository%20%3D%20Get-AzContainerRegistryRepository%20-RegistryName%20xxx%20-Name%20test%2Fbusybox%0A%0APS%3A%26gt%3B%20%24repository%0ARegistry%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%20xxx.azurecr.io%0AImageName%20%20%20%20%20%20%20%20%20%20%20%20%3A%20test%2Fbusybox%0ACreatedTime%20%20%20%20%20%20%20%20%20%20%3A%202021-02-02T04%3A11%3A14.4504049Z%0ALastUpdateTime%20%20%20%20%20%20%20%3A%202021-02-02T05%3A02%3A14.2671834Z%0AManifestCount%20%20%20%20%20%20%20%20%3A%201%0ATagCount%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%20150%0AChangeableAttributes%20%3A%20Microsoft.Azure.Commands.ContainerRegistry.Models.PSChangeableAttribute%0A%0APS%3A%26gt%3B%20%24repository.ChangeableAttributes%20%7C%20ft%0ADeleteEnabled%20WriteEnabled%20ListEnabled%20ReadEnabled%0A-------------%20%20%20%20%20%20%20%20%20%20------------%20%20%20%20%20%20%20%20%20%20-----------%20%20%20%20%20%20-----------%0A%20%20%20%20%20%20%20%20%20True%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20True%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20True%20%20%20%20%20%20%20%20%20%20%20%20True%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20also%20list%20all%20repository%20names%20under%20your%20registry%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPS%3A%26gt%3B%20Get-AzContainerRegistryRepository%20-RegistryName%20xxx%0Aalpine%0Atest%2Fbusybox%0Atest%2Fbusybox1%0Atest%2Fbusybox10%0Atest%2Fbusybox11%0Atest%2Fbusybox12%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20delete%20an%20existing%20repository%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPS%3A%26gt%3B%20Update-AzContainerRegistryRepository%20-RegistryName%20xxx%20-Name%20test%2Fbusybox%20-DeleteEnabled%20%24true%0APS%3A%26gt%3B%20Remove-%20AzContainerRegistryRepository%20-RegistryName%20xxx%20-Name%20test%2Fbusybox%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--1631760406%22%20id%3D%22toc-hId--1632602242%22%3EImages%3C%2FH1%3E%0A%3CP%3EGrouped%20in%20a%20repository%2C%20each%20image%20or%20artifact%20is%20a%20read-only%20multi-layer%20snapshot%20of%20a%20Docker-compatible%20container.%3C%2FP%3E%0A%3CP%3EAn%20artifact%20can%20be%20represented%20as%20either%20one%20of%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Emanifest%3C%2FLI%3E%0A%3CLI%3E%24repository_name%3A%24tag%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH2%20id%3D%22toc-hId--941198932%22%20id%3D%22toc-hId--942040768%22%3EManifest%3C%2FH2%3E%0A%3CP%3EEach%20image%20or%20other%20artifact%20pushed%20to%20a%20registry%20is%20associated%20with%20a%20JSON%20format%26nbsp%3B%3CEM%3Emanifest%3C%2FEM%3E.%20The%20manifest%2C%20generated%20by%20the%20registry%20when%20the%20content%20is%20pushed%2C%20uniquely%20identifies%20the%20artifact.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%22manifests%22%3A%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22digest%22%3A%20%22sha256%3A31a54a0cf86d7354788a8265f60ae6acb4b348a67efbcf7c1007dd3cf7af05ab%22%2C%0A%20%20%20%20%20%20%22imageSize%22%3A%20764633%2C%0A%20%20%20%20%20%20%22createdTime%22%3A%20%222020-12-11T09%3A17%3A20.4959715Z%22%2C%0A%20%20%20%20%20%20%22lastUpdateTime%22%3A%20%222020-12-11T09%3A17%3A20.4959715Z%22%2C%0A%20%20%20%20%20%20%22architecture%22%3A%20%22amd64%22%2C%0A%20%20%20%20%20%20%22os%22%3A%20%22linux%22%2C%0A%20%20%20%20%20%20%22mediaType%22%3A%20%22application%2Fvnd.docker.distribution.manifest.v2%2Bjson%22%2C%0A%20%20%20%20%20%20%22configMediaType%22%3A%20%22application%2Fvnd.docker.container.image.v1%2Bjson%22%2C%0A%20%20%20%20%20%20%22tags%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%22latest%22%0A%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%22changeableAttributes%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22deleteEnabled%22%3A%20false%2C%0A%20%20%20%20%20%20%20%20%22writeEnabled%22%3A%20true%2C%0A%20%20%20%20%20%20%20%20%22readEnabled%22%3A%20true%2C%0A%20%20%20%20%20%20%20%20%22listEnabled%22%3A%20true%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EManifests%20are%20identified%20by%20a%20unique%20SHA-256%20hash%2C%20%3CEM%3Emanifest%20digest%3C%2FEM%3E.%20Each%20image%20or%20artifact%2C%20whether%20tagged%20or%20not%2C%20is%20identified%20by%20its%20digest.%20The%20digest%20value%20is%20unique%20even%20if%20the%20artifact's%20layer%20data%20is%20identical%20to%20that%20of%20another%20artifact.%20This%20mechanism%20is%20what%20allows%20you%20to%20repeatedly%20push%20identically%20tagged%20images%20to%20a%20registry.%20For%20example%2C%20you%20can%20repeatedly%20push%26nbsp%3B%E2%80%9Cmyimage%3Alatest%E2%80%9D%26nbsp%3Bto%20your%20registry%20without%20error%20because%20each%20image%20is%20identified%20by%20its%20unique%20digest.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESimilarly%2C%20to%20get%2C%20list%2C%20update%2C%20or%20remove%20a%20manifest%20under%20a%20repository%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPS%3A%26gt%3B%20Get-AzContainerRegistryManifest%20-RegistryName%20xxx%20%0A-RepositoryName%20test%2Fbusybox50%20%0A-Name%20sha256%3A31a54a0cf86d7354788a8265f60ae6acb4b348a67efbcf7c1007dd3cf7af05ab%0ARegistry%20%20%20%3A%20xxx.azurecr.io%0AImageName%20%20%3A%20test%2Fbusybox50%0AAttributes%20%3A%20Microsoft.Azure.Commands.ContainerRegistry.Models.PSManifestAttributeBase%0A%0APS%3A%26gt%3B%20Get-AzContainerRegistryManifest%20-RegistryName%20xxx%20-RepositoryName%20test%2Fbusybox50%20%0A%0APS%3A%26gt%3B%20Update-AzContainerRegistryManifest%20-RegistryName%20xxx%20%0A-RepositoryName%20test%2Fbusybox50%20%0A-Manifest%20sha256%3A31a54a0cf86d7354788a8265f60ae6acb4b348a67efbcf7c1007dd3cf7af05ab%0A-DeleteEnabled%20%24true%0A%0APS%3A%26gt%3B%20Remove-AzContainerRegistryManifest%20-RegistryName%20xxx%20%0A-RepositoryName%20test%2Fbusybox50%20%0A-Manifest%20sha256%3A31a54a0cf86d7354788a8265f60ae6acb4b348a67efbcf7c1007dd3cf7af05ab%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlease%20be%20aware%20that%20to%20delete%20a%20repository%2C%20all%20manifests%20under%20it%20should%20have%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%22deleteEnabled%22%3A%20true%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1546313901%22%20id%3D%22toc-hId-1545472065%22%3ETag%3C%2FH2%3E%0A%3CP%3ETags%26nbsp%3Bfor%20an%20image%20or%20other%20artifact%20specifies%20its%20version.%20A%20single%20artifact%20within%20a%20repository%20can%20be%20assigned%20one%20or%20many%20tags%2C%20this%20artifact%20may%20also%20be%20%22untagged.%22%20That%20is%2C%20you%20can%20delete%20all%20tags%20from%20an%20image%2C%20while%20the%20image's%20data%20(its%20layers)%20remain%20in%20the%20registry.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%22tag%22%3A%20%7B%0A%20%20%20%20%22name%22%3A%20%22latest%22%2C%0A%20%20%20%20%22digest%22%3A%20%22sha256%3A31a54a0cf86d7354788a8265f60ae6acb4b348a67efbcf7c1007dd3cf7af05ab%22%2C%0A%20%20%20%20%22createdTime%22%3A%20%222020-12-11T09%3A17%3A20.6865195Z%22%2C%0A%20%20%20%20%22lastUpdateTime%22%3A%20%222020-12-11T09%3A17%3A20.6865195Z%22%2C%0A%20%20%20%20%22signed%22%3A%20false%2C%0A%20%20%20%20%22changeableAttributes%22%3A%20%7B%0A%20%20%20%20%20%20%22deleteEnabled%22%3A%20true%2C%0A%20%20%20%20%20%20%22writeEnabled%22%3A%20true%2C%0A%20%20%20%20%20%20%22readEnabled%22%3A%20true%2C%0A%20%20%20%20%20%20%22listEnabled%22%3A%20true%0A%20%20%20%20%7D%0A%20%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20repository%20plus%20a%20tag%20defines%20an%20image%20name.%20You%20can%20push%20and%20pull%20an%20image%20by%20specifying%20its%20name%20in%20the%20push%20or%20pull%20operation.%20The%20tag%26nbsp%3Blatest%26nbsp%3Bis%20used%20by%20default%20if%20you%20don't%20provide%20one%20in%20your%20Docker%20commands.%20As%20you%20can%20see%20in%20the%20ACR%20Overview%20section%2C%20%E2%80%9Crepository3%3Alatest%E2%80%9D%20and%20%E2%80%9Crepository3%3Av2%E2%80%9D%20both%20represent%20the%20same%20image%20%E2%80%9Cartifact3%E2%80%9D.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESimilarly%2C%20to%20get%2C%20list%2C%20update%2C%20%26nbsp%3Bor%20remove%20a%20tag%20for%20one%20artifact%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPS%3A%26gt%3B%20Get-AzContainerRegistryTag%20-RegistryName%20xxx%20%0A-RepositoryName%20test%2Fbusybox50%20%0A-Name%20latest%0ARegistry%20%20%20%3A%20xxx.azurecr.io%0AImageName%20%20%3A%20test%2Fbusybox50%0AAttributes%20%3A%20Microsoft.Azure.Commands.ContainerRegistry.Models.PSTagAttributeBase%0A%0APS%3A%26gt%3B%20Get-AzContainerRegistryTag%20-RegistryName%20xxx%20-RepositoryName%20test%2Fbusybox50%20%0A%0APS%3A%26gt%3B%20Update-AzContainerRegistryTag%20-RegistryName%20xxx%20%0A-RepositoryName%20test%2Fbusybox50%20%0A-Name%20latest%0A-DeleteEnabled%20%24true%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENotice%20that%20after%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPS%3A%26gt%3B%20Remove-AzContainerRegistryTag%20-RegistryName%20xxx%20%0A-RepositoryName%20test%2Fbusybox50%20%0A-Name%20latest%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20tag%20%E2%80%9Clatest%E2%80%9D%20was%20removed%20(untagged)%2C%20means%20you%20cannot%20find%3C%2FP%3E%0A%3CP%3E%E2%80%9Ctest%2Fbusybox50%3Alatest%E2%80%9D.%20In%20this%20repository%20anymore%2C%20but%20the%20corresponding%20artifact%20remained%20(get%20manifest)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPS%3A%26gt%3B%20%24digest%20%3D%20(Get-AzContainerRegistryTag%20-RegistryName%20xxx%20%0A-RepositoryName%20test%2Fbusybox50%20%0A-Name%20latest).%20Attributes.Digest%0A%0APS%3A%26gt%3B%20Get-AzContainerRegistryManifest%20-RegistryName%20xxx%20%0A-RepositoryName%20test%2Fbusybox50%20%0A-Name%20%24digest%0ARegistry%20%20%20%3A%20xxx.azurecr.io%0AImageName%20%20%3A%20test%2Fbusybox50%0AAttributes%20%3A%20Microsoft.Azure.Commands.ContainerRegistry.Models.PSManifestAttributeBase%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt%E2%80%99s%20also%20possible%20to%20update%20or%20delete%20a%20manifest%20by%20tag%2C%20it%E2%80%99s%20easier%20since%20it%E2%80%99s%20more%20recognizable%20to%20use%20a%20meaningful%20tag%20than%20series%20SHA256%26nbsp%3Bhash%20code%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPS%3A%26gt%3B%20Update-AzContainerRegistryManifest%20-RegistryName%20xxx%20%0A-RepositoryName%20test%2Fbusybox50%20%0A-Tag%20latest%0A-DeleteEnabled%20%24true%0A%0APS%3A%26gt%3B%20Remove-AzContainerRegistryManifest%20-RegistryName%20xxx%20%0A-RepositoryName%20test%2Fbusybox50%20%0A-Tag%20latest%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20way%2C%20not%20only%20the%20tag%2C%20but%20the%20artifact%20itself%20would%20also%20be%20deleted.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-1535810797%22%20id%3D%22toc-hId-1534968961%22%3EPerformance%3C%2FH1%3E%0A%3CP%3EWe%20found%20there%20are%20performance%20issues%20in%20each%20repository%2C%20manifest%2C%20and%20tag%20manipulating%20operation.%20They%20were%20all%20relatively%20slow%20because%20ACR%20categorized%20each%20operation%20with%20different%20scopes.%3C%2FP%3E%0A%3CP%3EA%20typical%20scope%20is%20in%20below%20format%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%E2%80%9C%24resource_type%3A%24resource_name%3A%24permission%E2%80%9D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20example%2C%20to%20list%20all%20tags%20under%20repository%20%E2%80%9Calpine%E2%80%9D%2C%20the%20scope%20for%20this%20operation%20would%20be%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%E2%80%9Crepository%3Aalpine%3Ametadata_read%E2%80%9D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20specific%20token%20required%20for%20this%20request%20is%20assigned%20based%20on%20the%20exact%20scope.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20these%20kinds%20of%20operations%2C%20there%20will%20be%202%20more%20extra%20HTTP%20requests%20sent%20out%20for%20token%20exchange%20before%20your%20actual%20operation.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EHTTP%20Method%3A%0APOST%0AAbsolute%20Uri%3A%0Ahttps%3A%2F%2Fxxx.azurecr.io%2Foauth2%2Ftoken%0A%0AHTTP%20Method%3A%0APOST%0AAbsolute%20Uri%3A%0Ahttps%3A%2F%2Fxxx.azurecr.io%2Foauth2%2FExchange%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20reduce%20these%20costly%20requests%2C%20we%20implemented%20a%20token%20cache%20in%20your%20current%20PowerShell%20session%2C%20it%20will%20cache%20all%20ACR%20tokens.%20For%20operations%20that%20used%20existing%20tokens%20(operations%20with%20same%20scope)%2C%20the%20previously%20referenced%20token%20exchange%20won%E2%80%99t%20happen%20until%20tokens%20in%20the%20cache%20expire.%20For%20repetitive%20operations%2C%20the%20total%20number%20of%20requests%20is%20now%20only%20one%20instead%20of%20three.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20clear%20this%20token%20cache%20in%20your%20current%20PowerShell%20session%20by%20running%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPS%3A%26gt%3B%20Clear-AzContext%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20cmdlet%20also%20terminates%20the%20login%20state%20for%20Azure.%20Remember%20to%20re-connect.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPS%3A%26gt%3B%20Connect-AzAccount%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--271643666%22%20id%3D%22toc-hId--272485502%22%3EConclusion%20%26amp%3B%20Feedback%3C%2FH1%3E%0A%3CP%3EWith%20these%20features%20added%2C%20Az.ContainerRegistry%20is%20now%20much%20more%20usable.%20It's%20highly%20recommended%20to%20download%20the%20latest%20module%20at%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.powershellgallery.com%2Fpackages%3Fq%3Daz.containerregistry%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fwww.powershellgallery.com%2Fpackages%3Fq%3Daz.containerregistry%3C%2FA%3E%3C%2FP%3E%0A%3CP%3Eand%20give%20a%20shot.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20also%20look%20forward%20to%20your%20feedback.%20Report%20issues%20at%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazure-powershell%2Fissues%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FAzure%2Fazure-powershell%2Fissues%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYabo%20Hu%3CBR%20%2F%3E%26nbsp%3BSoftware%20Engineer%3CBR%20%2F%3E%26nbsp%3BAzure-PowerShell%20Team%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2263008%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20can%20now%20login%2C%20manipulate%26nbsp%3Brepositories%2C%20manifests%2C%20and%20tags%20in%20your%20registry.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2263008%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Apr 08 2021 08:37 PM
Updated by: