Downloading a tarball from ACR with anonymous access
Create a registry with anonymous access enabled.
export REGISTRY_NAME=sphere
export REGISTRY=${REGISTRY_NAME} " .azurecr.io"
az acr create --name $REGISTRY_NAME --sku Premium --resource-group test --location wcus
az acr update -n $REGISTRY_NAME --anonymous-pull-enabled true
Push something with oras (alphine rootfs for example)
export REPO=alphine-tar
export TAG=3.9
curl -LO http://dl-cdn.alpinelinux.org/alpine/v3.9/releases/x86_64/alpine-minirootfs-3.9.4-x86_64.tar.gz
az acr login -n $REGISTRY_NAME
# oras push registry/repo:tag FILE_NAME:mediaType
oras push $REGISTRY /$REPO :$TAG ./alpine-minirootfs-3.9.4-x86_64.tar.gz:application/vnd.oci.image.layer.v1.tar+gzip
The following are the steps to download the files.
Get Anonymous Token
Get Manifest and digest of tarball from the manifest.
Download tarball and extract
export TOKEN=$( curl -s " https://$REGISTRY /oauth2/token?scope=repository%3A$REPO %3Apull&service=$REGISTRY " | jq -r ' .access_token' )
export DIGEST=$( curl -s -H " Authorization: Bearer $TOKEN " -H ' Accept: application/vnd.oci.image.manifest.v1+json' https://$REGISTRY /v2/$REPO /manifests/$TAG | jq -r ' .layers[0].digest' )
export FILE_NAME=$( echo $DIGEST | sed s/:/_/g)
# download and extract
curl -v -L -o $FILE_NAME -H " Authorization: Bearer $TOKEN " https://$REGISTRY /v2/$REPO /blobs/$DIGEST
mkdir extract
tar -xvf $FILE_NAME -C ./extract