azure-containerregistry-py
Azure Container Registry SDK for Python. Use for managing container images, artifacts, and repositories.
About this skill
This skill provides an interface to Azure Container Registry (ACR) through its Python SDK, enabling AI agents to programmatically manage container images, OCI artifacts, and repositories. Agents can perform operations such as listing repositories, tagging images, deleting artifacts, and querying image metadata, facilitating automated DevOps workflows and artifact management directly from an AI agent's execution environment. It leverages Azure Entra ID (formerly Azure Active Directory) for secure authentication via `DefaultAzureCredential`, streamlining access control and integration with Azure services.
Best use case
Automated cleanup of old or unused container images and artifacts in Azure Container Registry to reduce storage costs. Auditing container images for specific tags, vulnerabilities, or compliance requirements across repositories. Listing all repositories and images for inventory management, reporting, and asset tracking. Automating the deletion of specific images or entire repositories based on defined criteria (e.g., age, status, deprecation). Retrieving detailed metadata about container images or artifacts for analysis or integration with other systems. Implementing automated CI/CD pipeline steps for container image lifecycle management, such as promoting images or updating tags.
Azure Container Registry SDK for Python. Use for managing container images, artifacts, and repositories.
Successful execution of Azure Container Registry operations, such as listing repositories, deleting images, or retrieving artifact metadata, with clear feedback on the outcome to the AI agent, enabling further automated actions or reporting.
Practical example
Example input
List all container repositories currently active in my Azure Container Registry.
Example output
Successfully retrieved the following container repositories: ['my-web-app', 'data-processor', 'api-gateway', 'legacy-service']. There are a total of 4 repositories.
When to use this skill
- When an AI agent needs to programmatically interact with Azure Container Registry to manage container images, OCI artifacts, or repositories.
- When automating DevOps tasks related to container image lifecycle management, such as cleanup, versioning, auditing, or deployment preparation.
- When requiring secure, programmatic access to ACR for inventory management, compliance checks, or maintenance operations.
- When integrating ACR management capabilities directly into an AI-driven workflow, automation script, or cloud governance strategy.
When not to use this skill
- When interacting with container registries other than Azure Container Registry (e.g., Docker Hub, AWS ECR, Google Artifact Registry).
- When the task does not involve managing container images or OCI artifacts, but rather other Azure services (e.g., Azure Kubernetes Service, Azure Storage).
- When manual operations through the Azure Portal or Azure CLI are sufficient and preferred for one-off tasks.
- When network connectivity to Azure Container Registry is unavailable or restricted from the agent's execution environment.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/azure-containerregistry-py/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How azure-containerregistry-py Compares
| Feature / Agent | azure-containerregistry-py | Standard Approach |
|---|---|---|
| Platform Support | Claude | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | easy | N/A |
Frequently Asked Questions
What does this skill do?
Azure Container Registry SDK for Python. Use for managing container images, artifacts, and repositories.
Which AI agents support this skill?
This skill is designed for Claude.
How difficult is it to install?
The installation complexity is rated as easy. You can find the installation instructions above.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Azure Container Registry SDK for Python
Manage container images, artifacts, and repositories in Azure Container Registry.
## Installation
```bash
pip install azure-containerregistry
```
## Environment Variables
```bash
AZURE_CONTAINERREGISTRY_ENDPOINT=https://<registry-name>.azurecr.io
```
## Authentication
### Entra ID (Recommended)
```python
from azure.containerregistry import ContainerRegistryClient
from azure.identity import DefaultAzureCredential
client = ContainerRegistryClient(
endpoint=os.environ["AZURE_CONTAINERREGISTRY_ENDPOINT"],
credential=DefaultAzureCredential()
)
```
### Anonymous Access (Public Registry)
```python
from azure.containerregistry import ContainerRegistryClient
client = ContainerRegistryClient(
endpoint="https://mcr.microsoft.com",
credential=None,
audience="https://mcr.microsoft.com"
)
```
## List Repositories
```python
client = ContainerRegistryClient(endpoint, DefaultAzureCredential())
for repository in client.list_repository_names():
print(repository)
```
## Repository Operations
### Get Repository Properties
```python
properties = client.get_repository_properties("my-image")
print(f"Created: {properties.created_on}")
print(f"Modified: {properties.last_updated_on}")
print(f"Manifests: {properties.manifest_count}")
print(f"Tags: {properties.tag_count}")
```
### Update Repository Properties
```python
from azure.containerregistry import RepositoryProperties
client.update_repository_properties(
"my-image",
properties=RepositoryProperties(
can_delete=False,
can_write=False
)
)
```
### Delete Repository
```python
client.delete_repository("my-image")
```
## List Tags
```python
for tag in client.list_tag_properties("my-image"):
print(f"{tag.name}: {tag.created_on}")
```
### Filter by Order
```python
from azure.containerregistry import ArtifactTagOrder
# Most recent first
for tag in client.list_tag_properties(
"my-image",
order_by=ArtifactTagOrder.LAST_UPDATED_ON_DESCENDING
):
print(f"{tag.name}: {tag.last_updated_on}")
```
## Manifest Operations
### List Manifests
```python
from azure.containerregistry import ArtifactManifestOrder
for manifest in client.list_manifest_properties(
"my-image",
order_by=ArtifactManifestOrder.LAST_UPDATED_ON_DESCENDING
):
print(f"Digest: {manifest.digest}")
print(f"Tags: {manifest.tags}")
print(f"Size: {manifest.size_in_bytes}")
```
### Get Manifest Properties
```python
manifest = client.get_manifest_properties("my-image", "latest")
print(f"Digest: {manifest.digest}")
print(f"Architecture: {manifest.architecture}")
print(f"OS: {manifest.operating_system}")
```
### Update Manifest Properties
```python
from azure.containerregistry import ArtifactManifestProperties
client.update_manifest_properties(
"my-image",
"latest",
properties=ArtifactManifestProperties(
can_delete=False,
can_write=False
)
)
```
### Delete Manifest
```python
# Delete by digest
client.delete_manifest("my-image", "sha256:abc123...")
# Delete by tag
manifest = client.get_manifest_properties("my-image", "old-tag")
client.delete_manifest("my-image", manifest.digest)
```
## Tag Operations
### Get Tag Properties
```python
tag = client.get_tag_properties("my-image", "latest")
print(f"Digest: {tag.digest}")
print(f"Created: {tag.created_on}")
```
### Delete Tag
```python
client.delete_tag("my-image", "old-tag")
```
## Upload and Download Artifacts
```python
from azure.containerregistry import ContainerRegistryClient
client = ContainerRegistryClient(endpoint, DefaultAzureCredential())
# Download manifest
manifest = client.download_manifest("my-image", "latest")
print(f"Media type: {manifest.media_type}")
print(f"Digest: {manifest.digest}")
# Download blob
blob = client.download_blob("my-image", "sha256:abc123...")
with open("layer.tar.gz", "wb") as f:
for chunk in blob:
f.write(chunk)
```
## Async Client
```python
from azure.containerregistry.aio import ContainerRegistryClient
from azure.identity.aio import DefaultAzureCredential
async def list_repos():
credential = DefaultAzureCredential()
client = ContainerRegistryClient(endpoint, credential)
async for repo in client.list_repository_names():
print(repo)
await client.close()
await credential.close()
```
## Clean Up Old Images
```python
from datetime import datetime, timedelta, timezone
cutoff = datetime.now(timezone.utc) - timedelta(days=30)
for manifest in client.list_manifest_properties("my-image"):
if manifest.last_updated_on < cutoff and not manifest.tags:
print(f"Deleting {manifest.digest}")
client.delete_manifest("my-image", manifest.digest)
```
## Client Operations
| Operation | Description |
|-----------|-------------|
| `list_repository_names` | List all repositories |
| `get_repository_properties` | Get repository metadata |
| `delete_repository` | Delete repository and all images |
| `list_tag_properties` | List tags in repository |
| `get_tag_properties` | Get tag metadata |
| `delete_tag` | Delete specific tag |
| `list_manifest_properties` | List manifests in repository |
| `get_manifest_properties` | Get manifest metadata |
| `delete_manifest` | Delete manifest by digest |
| `download_manifest` | Download manifest content |
| `download_blob` | Download layer blob |
## Best Practices
1. **Use Entra ID** for authentication in production
2. **Delete by digest** not tag to avoid orphaned images
3. **Lock production images** with can_delete=False
4. **Clean up untagged manifests** regularly
5. **Use async client** for high-throughput operations
6. **Order by last_updated** to find recent/old images
7. **Check manifest.tags** before deleting to avoid removing tagged images
## When to Use
This skill is applicable to execute the workflow or actions described in the overview.Related Skills
azure-resource-manager-sql-dotnet
Azure Resource Manager SDK for Azure SQL in .NET.
azure-resource-manager-redis-dotnet
Azure Resource Manager SDK for Redis in .NET.
azure-resource-manager-postgresql-dotnet
Azure PostgreSQL Flexible Server SDK for .NET. Database management for PostgreSQL Flexible Server deployments.
azure-resource-manager-mysql-dotnet
Azure MySQL Flexible Server SDK for .NET. Database management for MySQL Flexible Server deployments.
azure-resource-manager-cosmosdb-dotnet
Azure Resource Manager SDK for Cosmos DB in .NET.
azure-monitor-query-py
Azure Monitor Query SDK for Python. Use for querying Log Analytics workspaces and Azure Monitor metrics.
azure-mgmt-weightsandbiases-dotnet
Azure Weights & Biases SDK for .NET. ML experiment tracking and model management via Azure Marketplace. Use for creating W&B instances, managing SSO, marketplace integration, and ML observability.
azure-mgmt-botservice-py
Azure Bot Service Management SDK for Python. Use for creating, managing, and configuring Azure Bot Service resources.
azure-mgmt-botservice-dotnet
Azure Resource Manager SDK for Bot Service in .NET. Management plane operations for creating and managing Azure Bot resources, channels (Teams, DirectLine, Slack), and connection settings.
azure-mgmt-apicenter-py
Azure API Center Management SDK for Python. Use for managing API inventory, metadata, and governance across your organization.
azure-keyvault-certificates-rust
Azure Key Vault Certificates SDK for Rust. Use for creating, importing, and managing certificates.
cost-optimization
Strategies and patterns for optimizing cloud costs across AWS, Azure, and GCP.