I am trying to migrate Gitlab-ce Container Registry to Azure Container Registry :
the command im using :
az acr import \
--name acr name\
--source gitlab/repo/repo/tag
--username ****\
--password *****
and it works.
what im trying to do now since there is no direct migration in the internet is to create a script to automate the migration process
my idea is like this :
# Get list of projects,repos and tags
repos = i couldn't find a command to list the repos
for project in project do:
repos = get all repos
for repo in repos do:
tags = get all tags
az acr import \
--name acr name\
--source gitlab/$project/$repo/$tag
--username ****\
--password *****
done
done
The Problem is i couldn't find any command to list project,repos or tags using gitlab command line
is there another way to automate the migration if i couldn't find the commands ??
Please check if below commands can give an idea to work around:
Here we try to use the Azure CLI commands az acr repository list and az acr repository show-tags to include image tags in a loop.
SOURCE_REGISTRY=myregistry
TARGET_REGISTRY=targetregistry
# Get list of source repositories
REPOS = $(az acr repository list \ --name $SOURCE_REGISTRY --output tsv)
# Enumerate tags and import to target registry
for repo in $REPOS; do
TAGS= $(az acr repository show-tags --name $OURCE_REGISTRY --repository $repo --output tsv);
for tag in $TAGS; do
echo "Importing $repo:$tag";
az acr import --name $TARGET_REGISTRY --source $SOURCE_REGISTRY /$repo":"$tag --username <username> --password <password> ;
done
done
also please check the Azure PowerShell equivalents as in Reference: Microsoft Docs and almost similar to Stack Overflow thread
References:
Moving docker images from one container registry to another | by Paulo Gomes | Medium
container-registry-import-images | Microsoft Docs
Related
Looking for an example in GitHub actions workflow to clone a specifc image name by commit SHA from GHCR (GitHub registry) to ACR (Azure registry) with a need to copy all the tags and labels from the source repository to the target.
At the moment, I'm using Docker pull and push commands, but didn't find a way to fetch all the tags for given image sha from GHCR.
Appreciate your help,
Thanks.
I tried in my environment and got beow results:
To copy Github container registry to azure container registry, You can use the following this command.
Command:
az login
az acr login -n < your acr container registry >
az acr import \
--name <container registry > \
--source <ghcr.io/< username >/image:latest \
--username <Git-hub RegistryUsername> \
--password <Git-hub RegistryPassword>
Console:
Portal:
For more reference:
Import container images - Azure Container Registry | Microsoft Learn
Have a question on Azure need to deploy an azure container app by pulling the image from azure container registry from AZ
Steps:
1- az login -successful
2- az acr login appdev - successful
3- az containerapp create --name apptest --resource-group \
testapp --image appdev.azurecr.io/dev/dev-app:latest \
--environment MyContainerappEnv \
Throwing this error:
the following field(s) are either invalid or missing. Invalid value: "appdev.azurecr.io/dev/dev-app:latest": GET https:?scope=repository%3Adev%2Fdev-app%3Apull&service=appdev.azurecr.io: UNAUTHORIZED: authentication required, visit https://aka.ms/acr/authorization for more information.: template.containers.apptest.image
I have already logged in successfully and able to pull the image using
docker pull appdev.azurecr.io/dev/dev-app:latest
Also this is successful
az acr login --name appdev
Login Succeeded
Able to push the image to ACR .
I already have contributor permission to the subscription.
Can anyone help? Thanks
this worked:
az containerapp create --name apptest \
--resource-group testapp \
--image appdev.azurecr.io/dev/dev-app:latest \
--environment MyContainerappEnv \
--registry-server appdev.azurecr.io //adding this
Go to
your container registry => Access token => set admin user to "enabled"
You should add a commend below during creating az containerapp using Azure CLI.:
--registry-server appdev.azurecr.io
Azure Container Registry:
`az acr create --resource-group $RESOURCE_GROUP --name $ACR_NAME --sku Basic '--admin-enabled true
I'm trying to setup a script for automate the creation of a new environment for my app, and i need a docker webapp.
The problem is that i need to pull the image from docker hub.
When i create an env from the interface in juste setup it like that :
The problem is that i don't find out how i can configure the "Source de registre" on Docker Hub by the az cli.
For now the command i'm using to create a new web app ressource is this one
az webapp create -g name_of_group -p name_of_plan -n resource-test2 -i https://registry.hub.docker.com/publisher/name_of_image:version -s name_of_image -w my_password
The problem of this command is that it give me this configuration
Which doesn't work because i can't get logged in (probably because it's not configured as a Docker Hub registre).
Do you know how i can specify this configuration in my az cli command ? Thanks
To deploy the images stored in a private registry or the Docker Hub, you can set the environment variables below:
DOCKER_REGISTRY_SERVER_USERNAME - The username for the ACR server.
DOCKER_REGISTRY_SERVER_URL - The full URL to the ACR server. (For example, https://my-server.azurecr.io.)
DOCKER_REGISTRY_SERVER_PASSWORD - The password for the ACR server.
Get more details here. And you can use the CLI command az webapp config appsettings set to do it.
Recently had the same problem deploying azure cloud webapp from a container in my private docker hub repo. UI experience works fine but when I do it using azure cli with 'az webapp create ...' ended up with same problem. I was able to fix it by using 'az webapp config container set ...' command after creating the webapp. See below and in my github repo
# First create the webapp with a docker container:
~$ az webapp create -n $webAppName -g $resGroup -p $servicePlan -i $containerImg -s $dockerUsr -w $dockerPass --tags Lifecycle=Test
# Update docker container settings with your private docker hub repo credentials:
~$ az webapp config container set --name $webAppName --resource-group $resGroup --docker-custom-image-name 'DOCKER|dockeruser/myrepo:tweb1' --docker-registry-server-url 'https://index.docker.io/v1' --docker-registry-server-user 'dockeruser' --docker-registry-server-password 'xxxxxxxxxxx'
Getting below error while deleting ACR repository or image.
Command: $ az acr repository delete --name pocacr2021 -repository repoNodeBulletin
Error: The requested data does not exist. Correlation Id:xxxx-xxxxx-xxxx-xxxxx
Error was coming due to passing repository name should be lower case. It won't allow upper or mixed case.
Wrong Command: $ az acr repository delete --name pocacr2021 -repository repoNodeBulletin
Correct Command: $ az acr repository delete --name pocacr2021 -repository reponodebulletin
When building my docker image locally and import it to Azure Container Registry (ACR), the Image platform is Windows. It should be Linux. How can I import my image as a Linux platform?
I am using this command to import the image to my ACR.
az acr import
By using the command az acr import means that you can import an image to an Azure Container Registry from another Container Registry. So you should have container images from a public registry or another Azure container registry, in the same or a different Azure subscription or tenant or from a non-Azure private container registry. Read Import container images to a container registry for more details.
In this case, if you have built the images locally, you can push the images directly to the ACR instead of using import. You can make it as the Tutorial: Create an Azure container registry and push a container image:
log in to your Azure Container Registry instance
az acr login --name <acrName>
tag the image with the full name of the registry's login server.
docker tag <localImage> <acrLoginServer>/<acrRepository>:<tag>
Push image to Azure Container Registry
docker push <acrLoginServer>/<acrRepository>:<tag>
Use the following command to import from another ACR from a different subscription.
az acr import --name <DESTINATION-ACR> --force\
--source <SOURCE-ACR-NAME>/IMAGE-NAME:IMAGE-TAG \
--image IMAGE-NAME:IMAGE-TAG \
--username <USERNAME> \
--password <PASSWORD>