azure - 如何将所有图像从 ACR 存储库导入到不同租户中的另一个 ACR

标签 azure azure-container-registry

场景:我在 ACR(azure 容器注册表)中有 4 个存储库,每个存储库中有多个图像。我想将所有存储库和其中的所有图像移动到不同的 ACR(azure 容器注册表) 我所做的:我使用以下命令将 ACR(azure 容器注册表)存储库中的单个镜像导入到另一个 ACR 存储库。

az acr import \
  --name myregistry \
  --source sourceregistry.azurecr.io/sourcerrepo:tag \
  --image targetimage:tag \
  --username <SP_App_ID> \
  --password <SP_Passwd>

问题:以上命令仅根据给定的标签导入单个图像。

所需解决方案:我想要实现的是将 ACR 的单个存储库内的所有图像导入到不同的 ACR。

如果有人有任何解决方案,请告诉我。

最佳答案

使用 pwsh 和 az cli 启动此脚本:

$SourceAcrName="source ACR Name"
$DestinationAcrName="destination ACR Name"

$Repos= az acr repository list --name $SourceAcrName | ConvertFrom-Json

foreach ($repo in $Repos) {
    $Tags = az acr repository show-tags -n $SourceAcrName --repository $repo | ConvertFrom-Json
    foreach ($tag in $Tags) {
        az acr import -r $SourceAcrName -n $DestinationAcrName --source "${repo}:${tag}" --no-wait
    }
}

它将把 ACR 中的所有存储库和标签复制到目标 ACR。 --no-wait 参数允许任务在 Azure 后台运行,因此您无需等待确认。

关于azure - 如何将所有图像从 ACR 存储库导入到不同租户中的另一个 ACR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67749357/

相关文章:

azure - 使用 az cli 将参数传递到 --custom-data Cloud Init 脚本

Azure DevOps Pipeline yaml 文件 Docker 标签

Azure部署部署参数 'dockerRegistryUrl'值为空

Azure DevOps - Maven Pipeline 发布 Artifact

Azure 开发运营 : Add Azure Container Registry in Build Pipeline from different account

Azure DevOps Pipeline - 构建 Docker 镜像并将其推送到具有受限网络访问权限的 Azure 容器注册表

azure - 将Azure容器应用程序部署到Azure管道中的不同资源组

azure - 错误 2013 - 查询期间丢失与 MySQL 服务器的连接

azure - Traefik 与 Service Fabric — 无法连接到 Service Fabric 服务器

c# - 运行 powershell 脚本时云无法加载文件或程序集 'System.Management.Automation'