public override void Run(CancellationToken cancellationToken) { foreach (var manifest in _repository.GetManifestPropertiesCollection()) { _client.GetArtifact($"library/node", manifest.Digest); } }
public async Task AnonymouslyListTagsAsync() { Environment.SetEnvironmentVariable("REGISTRY_ENDPOINT", TestEnvironment.AnonymousAccessEndpoint); #region Snippet:ContainerRegistry_Tests_Samples_ListTagsAnonymousAsync // Get the service endpoint from the environment Uri endpoint = new Uri(Environment.GetEnvironmentVariable("REGISTRY_ENDPOINT")); // Create a new ContainerRegistryClient for anonymous access ContainerRegistryClient client = new ContainerRegistryClient(endpoint, new ContainerRegistryClientOptions() { Audience = ContainerRegistryAudience.AzureResourceManagerPublicCloud }); // Obtain a RegistryArtifact object to get access to image operations RegistryArtifact image = client.GetArtifact("library/hello-world", "latest"); // List the set of tags on the hello_world image tagged as "latest" AsyncPageable <ArtifactTagProperties> tags = image.GetAllTagPropertiesAsync(); // Iterate through the image's tags, listing the tagged alias for the image Console.WriteLine($"{image.FullyQualifiedReference} has the following aliases:"); await foreach (ArtifactTagProperties tag in tags) { Console.WriteLine($" {image.RegistryEndpoint.Host}/{image.RepositoryName}:{tag}"); } #endregion }
public async Task SetImagePropertiesAsync() { // Set up await ImportImageAsync(TestEnvironment.Registry, "library/hello-world", new List <string>() { "v1", "latest" }); Environment.SetEnvironmentVariable("REGISTRY_ENDPOINT", TestEnvironment.Endpoint); #region Snippet:ContainerRegistry_Tests_Samples_SetArtifactPropertiesAsync // Get the service endpoint from the environment Uri endpoint = new Uri(Environment.GetEnvironmentVariable("REGISTRY_ENDPOINT")); // Create a new ContainerRegistryClient and RegistryArtifact to access image operations ContainerRegistryClient client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential()); RegistryArtifact image = client.GetArtifact("library/hello-world", "v1"); // Set permissions on the image's "latest" tag await image.UpdateTagPropertiesAsync("latest", new ArtifactTagProperties() { CanWrite = false, CanDelete = false }); #endregion // Reset registry state await image.UpdateTagPropertiesAsync("latest", new ArtifactTagProperties() { CanRead = true, CanList = true, CanWrite = true, CanDelete = true }); }
private static void ProcessRepository(ContainerRegistryClient client, string repositoryName, ILogger log) { log.LogInformation($"Processing repository {repositoryName} ..."); var tasks = new List <Task>(); Azure.Containers.ContainerRegistry.ContainerRepository repository = client.GetRepository(repositoryName); var manifests = repository.GetManifestPropertiesCollection(); foreach (var manifest in manifests) { if (manifest.Tags.Count < 1) { log.LogInformation($"Found untagged manifest {repositoryName}:{manifest.Digest}. Will delete."); tasks.Add(client.GetArtifact(repositoryName, manifest.Digest).DeleteAsync()); } } try { Task.WaitAll(tasks.ToArray()); } catch (AggregateException ae) { foreach (var e in ae.InnerExceptions) { log.LogError(e.Message); } } }