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.
Asked
Active
Viewed 3,089 times
1
-
1[this](https://github.com/Azure/azure-cli/blob/dbe24401b163ac2bac4f993982375296414b81b7/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/repository.py#L283) is the code used to delete the image with CLI. you can reverse it. weird enough i dont see a rest call for that – 4c74356b41 Aug 20 '18 at 06:10
2 Answers
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

Hong Ooi
- 56,353
- 13
- 134
- 187
-
pretty cool, dont have time to read, but will definitely check it out later, thanks! – 4c74356b41 Aug 20 '18 at 08:29
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);
});

Sam
- 5,375
- 2
- 45
- 54