azure-sdk-for-go/sdk/containers/azcontainerregistry
Wes Haggard ac22295fff
Switch to TME test subscription (#23570)
2024-10-14 16:54:41 -07:00
..
testdata azcontainerregistry tests build images instead of importing them (#23329) 2024-08-20 10:17:38 -07:00
CHANGELOG.md Increment package version after release of containers/azcontainerregistry (#23465) 2024-09-19 11:14:03 -07:00
LICENSE.txt
README.md add TSG for azcontainerregistry (#20895) 2023-05-25 09:11:24 +08:00
TROUBLESHOOTING.md add TSG for azcontainerregistry (#20895) 2023-05-25 09:11:24 +08:00
assets.json azcontainerregistry tests build images instead of importing them (#23329) 2024-08-20 10:17:38 -07:00
authentication_client.go azcontainerregistry: expose authentication client, options (#23285) 2024-08-08 13:52:15 +08:00
authentication_client_test.go azcontainerregistry: expose authentication client, options (#23285) 2024-08-08 13:52:15 +08:00
authentication_custom_client.go azcontainerregistry: expose authentication client, options (#23285) 2024-08-08 13:52:15 +08:00
authentication_custom_client_test.go azcontainerregistry: expose authentication client, options (#23285) 2024-08-08 13:52:15 +08:00
authentication_policy.go azcontainerregistry: expose authentication client, options (#23285) 2024-08-08 13:52:15 +08:00
authentication_policy_test.go azcontainerregistry tests build images instead of importing them (#23329) 2024-08-20 10:17:38 -07:00
autorest.md azcontainerregistry: expose authentication client, options (#23285) 2024-08-08 13:52:15 +08:00
blob_client.go Refresh azcontainerregistry module (#22161) 2024-01-10 09:30:49 +08:00
blob_client_test.go azcontainerregistry tests build images instead of importing them (#23329) 2024-08-20 10:17:38 -07:00
blob_custom_client.go azcontainerregistry: expose authentication client, options (#23285) 2024-08-08 13:52:15 +08:00
blob_custom_client_test.go azcontainerregistry tests build images instead of importing them (#23329) 2024-08-20 10:17:38 -07:00
build.go Remove autorest core version from build scripts (#20995) 2023-06-08 17:11:17 -07:00
ci.yml Switch to TME test subscription (#23570) 2024-10-14 16:54:41 -07:00
client.go Refresh azcontainerregistry module (#22161) 2024-01-10 09:30:49 +08:00
client_test.go azcontainerregistry tests build images instead of importing them (#23329) 2024-08-20 10:17:38 -07:00
cloud_config.go
constants.go azcontainerregistry: expose authentication client, options (#23285) 2024-08-08 13:52:15 +08:00
constants_test.go azcontainerregistry: expose authentication client, options (#23285) 2024-08-08 13:52:15 +08:00
custom_client.go azcontainerregistry: expose authentication client, options (#23285) 2024-08-08 13:52:15 +08:00
custom_client_test.go
custom_constants.go Increment package version after release of containers/azcontainerregistry (#23465) 2024-09-19 11:14:03 -07:00
digest_helper.go refine some logics and comments according to ACR service team's review (#20981) 2023-06-08 09:57:14 +08:00
digest_helper_test.go add digest validation utils and examples (#20887) 2023-05-31 17:37:13 +08:00
example_blob_client_test.go azcontainerregistry linting (#23020) 2024-06-07 23:25:48 +00:00
example_blob_custom_client_test.go add digest validation utils and examples (#20887) 2023-05-31 17:37:13 +08:00
example_client_test.go add digest validation utils and examples (#20887) 2023-05-31 17:37:13 +08:00
example_custom_client_test.go add digest validation utils and examples (#20887) 2023-05-31 17:37:13 +08:00
example_delete_images_test.go
example_download_image_test.go add digest validation utils and examples (#20887) 2023-05-31 17:37:13 +08:00
example_list_repositories_test.go
example_list_tags_test.go
example_set_artifact_properties_test.go
example_upload_image_test.go add digest validation utils and examples (#20887) 2023-05-31 17:37:13 +08:00
go.mod Prepare azcontainerregistry v0.2.2 for release (#23463) 2024-09-19 00:15:10 +00:00
go.sum Prepare azcontainerregistry v0.2.2 for release (#23463) 2024-09-19 00:15:10 +00:00
models.go azcontainerregistry: expose authentication client, options (#23285) 2024-08-08 13:52:15 +08:00
models_serde.go azcontainerregistry: expose authentication client, options (#23285) 2024-08-08 13:52:15 +08:00
options.go azcontainerregistry: expose authentication client, options (#23285) 2024-08-08 13:52:15 +08:00
response_types.go azcontainerregistry: expose authentication client, options (#23285) 2024-08-08 13:52:15 +08:00
test-resources-post.ps1 Use common OIDC token env vars in post scripts (#23549) 2024-10-10 21:11:30 +00:00
test-resources.bicep azcontainerregistry tests build images instead of importing them (#23329) 2024-08-20 10:17:38 -07:00
time_rfc3339.go Refresh azcontainerregistry module (#22161) 2024-01-10 09:30:49 +08:00
time_rfc3339_test.go Refresh azcontainerregistry module (#22161) 2024-01-10 09:30:49 +08:00
utils_test.go Use common OIDC token env vars in post scripts (#23549) 2024-10-10 21:11:30 +00:00

README.md

Azure Container Registry client module for Go

Azure Container Registry allows you to store and manage container images and artifacts in a private registry for all types of container deployments.

Use the client library for Azure Container Registry to:

  • List images or artifacts in a registry
  • Obtain metadata for images and artifacts, repositories and tags
  • Set read/write/delete properties on registry items
  • Delete images and artifacts, repositories and tags
  • Upload and download images

Source code | Package (pkg.go.dev) | REST API documentation | Product documentation

Getting started

Install packages

Install azcontainerregistry and azidentity with go get:

go get github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry
go get github.com/Azure/azure-sdk-for-go/sdk/azidentity

azidentity is used for Azure Active Directory authentication as demonstrated below.

Prerequisites

To create a new Container Registry, you can use the Azure Portal, Azure PowerShell, or the Azure CLI. Here's an example using the Azure CLI:

az acr create --name MyContainerRegistry --resource-group MyResourceGroup --location westus --sku Basic

Authentication

This document demonstrates using azidentity.NewDefaultAzureCredential to authenticate. This credential type works in both local development and production environments. We recommend using a managed identity in production.

Client and BlobClient accepts any [azidentity][https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity] credential. See the azidentity documentation for more information about other credential types.

Create a client

Constructing the client requires your Container Registry's endpoint URL, which you can get from the Azure CLI (loginServer value returned by az acr list) or the Azure Portal (Login server value on registry overview page).

import (
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}

	client, err := azcontainerregistry.NewClient("<your Container Registry's endpoint URL>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
}

Key concepts

A registry stores Docker images and OCI Artifacts. An image or artifact consists of a manifest and layers. An image's manifest describes the layers that make up the image, and is uniquely identified by its digest. An image can also be "tagged" to give it a human-readable alias. An image or artifact can have zero or more tags associated with it, and each tag uniquely identifies the image. A collection of images that share the same name but have different tags, is referred to as a repository.

For more information please see Container Registry Concepts.

Examples

Get started with our examples.

Troubleshooting

For information about troubleshooting, refer to the troubleshooting guide.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct][https://opensource.microsoft.com/codeofconduct/]. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.