1

Is there a way to manipulate images in Azure Container Registry (delete, retag, etc) using the REST API? The answers to an existing question only mention the CLI.

1
  • 1
    this is the code used to delete the image with CLI. you can reverse it. weird enough i dont see a rest call for that Commented Aug 20, 2018 at 6:10

2 Answers 2

9

The answer is that ACR implements the Docker Registry API, so all the commands listed there will also work for images in an Azure registry. This is distinct to the Resource Manager REST interface, which is meant for operations on the registry itself.

To authenticate, there are various options listed in the ACR docs including via AAD or with a username/password: https://github.com/Azure/acr/blob/master/docs/AAD-OAuth.md

For example, here is the script from AAD-OAuth.md to list all the images/repos in a registry:

#!/bin/bash

export registry=" --- you have to fill this out --- "
export user=" --- you have to fill this out --- "
export password=" --- you have to fill this out --- "

export operation="/v2/_catalog"

export credentials=$(echo -n "$user:$password" | base64 -w 0)

export catalog=$(curl -s -H "Authorization: Basic $credentials" https://$registry$operation)
echo "Catalog"
echo $catalog
Sign up to request clarification or add additional context in comments.

1 Comment

pretty cool, dont have time to read, but will definitely check it out later, thanks!
0

This is some sample code on how to get a list of images with Node.js:

const httpreq = require('httpreq');

const server   = '<get it from the Azure portal>';
const username = '<get it from the Azure portal>';
const password = '<get it from the Azure portal>';

httpreq.get(`https://${server}/v2/_catalog`, {
    auth: `${username}:${password}`
}, (err, res) => {
    if(err) return console.log(err);
    var data = JSON.parse(res.body);
    console.log(data);
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.