@@ -39,20 +39,20 @@ More information at [Azure Container Registry portal][container_registry_create_
3939
4040<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L29-L33 -->
4141``` Java
42- ContainerRegistryClient client = new ContainerRegistryClientBuilder ()
43- .endpoint(endpoint )
44- .credential(credential )
45- .buildClient();
46- }
42+ DefaultAzureCredential credential = new DefaultAzureCredentialBuilder () . build();
43+ ContainerRegistryClient client = new ContainerRegistryClientBuilder ( )
44+ .endpoint(endpoint )
45+ .credential(credential)
46+ .buildClient();
4747```
4848
4949<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L37-L41 -->
5050``` Java
51- ContainerRegistryAsyncClient client = new ContainerRegistryClientBuilder ()
52- .endpoint(endpoint )
53- .credential(credential )
54- .buildAsyncClient();
55- }
51+ DefaultAzureCredential credential = new DefaultAzureCredentialBuilder () . build();
52+ ContainerRegistryAsyncClient client = new ContainerRegistryClientBuilder ( )
53+ .endpoint(endpoint )
54+ .credential(credential)
55+ .buildAsyncClient();
5656```
5757
5858For more information on using AAD with Azure Container Registry, please see the service's [ Authentication Overview] ( https://docs.microsoft.com/azure/container-registry/container-registry-authentication ) .
@@ -63,14 +63,14 @@ The user must use this setting on a registry that has been enabled for anonymous
6363In this mode, the user can only call listRepositoryNames method and its overload. All the other calls will fail.
6464For more information please read [ Anonymous Pull Access] ( https://docs.microsoft.com/azure/container-registry/container-registry-faq#how-do-i-enable-anonymous-pull-access )
6565
66- <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L70-L72 -->
66+ <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L71-L73 -->
6767``` Java
6868ContainerRegistryClient client = new ContainerRegistryClientBuilder ()
6969 .endpoint(endpoint)
7070 .buildClient();
7171```
7272
73- <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L76-L78 -->
73+ <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L77-L79 -->
7474``` Java
7575ContainerRegistryAsyncClient client = new ContainerRegistryClientBuilder ()
7676 .endpoint(endpoint)
@@ -105,7 +105,7 @@ For more information please see [Container Registry Concepts](https://docs.micro
105105
106106Iterate through the collection of repositories in the registry.
107107
108- <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L44-L50 -->
108+ <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L45-L51 -->
109109``` Java
110110DefaultAzureCredential credential = new DefaultAzureCredentialBuilder (). build();
111111ContainerRegistryClient client = new ContainerRegistryClientBuilder ()
@@ -118,16 +118,16 @@ client.listRepositoryNames().forEach(repository -> System.out.println(repository
118118
119119### List tags with anonymous access
120120
121- <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L137-L148 -->
121+ <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L138-L149 -->
122122``` Java
123123ContainerRegistryClient anonymousClient = new ContainerRegistryClientBuilder ()
124124 .endpoint(endpoint)
125125 .buildClient();
126126
127127RegistryArtifact image = anonymousClient. getArtifact(repositoryName, digest);
128- PagedIterable<ArtifactTagProperties > tags = image. listTags ();
128+ PagedIterable<ArtifactTagProperties > tags = image. listTagProperties ();
129129
130- System . out. printf(String . format(" %s has the following aliases:" , image. getFullyQualifiedName ()));
130+ System . out. printf(String . format(" %s has the following aliases:" , image. getFullyQualifiedReference ()));
131131
132132for (ArtifactTagProperties tag : tags) {
133133 System . out. printf(String . format(" %s/%s:%s" , anonymousClient. getEndpoint(), repositoryName, tag. getName()));
@@ -136,7 +136,7 @@ for (ArtifactTagProperties tag : tags) {
136136
137137### Set artifact properties
138138
139- <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L116-L129 -->
139+ <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L117-L130 -->
140140``` Java
141141TokenCredential defaultCredential = new DefaultAzureCredentialBuilder (). build();
142142
@@ -156,7 +156,7 @@ image.updateTagProperties(
156156
157157### Delete Images
158158
159- <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L82-L110 -->
159+ <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L83-L111 -->
160160``` Java
161161TokenCredential defaultCredential = new DefaultAzureCredentialBuilder (). build();
162162
@@ -171,8 +171,8 @@ for (String repositoryName : client.listRepositoryNames()) {
171171
172172 // Obtain the images ordered from newest to oldest
173173 PagedIterable<ArtifactManifestProperties > imageManifests =
174- repository. listManifests (
175- ManifestOrderBy . LAST_UPDATED_ON_DESCENDING ,
174+ repository. listManifestProperties (
175+ ArtifactManifestOrderBy . LAST_UPDATED_ON_DESCENDING ,
176176 Context . NONE );
177177
178178 imageManifests. stream(). skip(imagesCountToKeep)
@@ -190,7 +190,7 @@ for (String repositoryName : client.listRepositoryNames()) {
190190```
191191
192192### Delete repository with anonymous access throws
193- <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L152-L164 -->
193+ <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L153-L165 -->
194194``` Java
195195final String endpoint = getEndpoint();
196196final String repositoryName = getRepositoryName();
@@ -202,7 +202,7 @@ ContainerRegistryClient anonymousClient = new ContainerRegistryClientBuilder()
202202try {
203203 anonymousClient. deleteRepository(repositoryName);
204204 System . out. println(" Unexpected Success: Delete is not allowed on anonymous access" );
205- } catch (Exception ex) {
205+ } catch (ClientAuthenticationException ex) {
206206 System . out. println(" Expected exception: Delete is not allowed on anonymous access" );
207207}
208208```
@@ -212,19 +212,20 @@ try {
212212All container registry service operations will throw a
213213[ HttpResponseException] [ HttpResponseException ] on failure.
214214
215- <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L56-L66 -->
215+ <!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L56-L67 -->
216216``` Java
217- DefaultAzureCredential credential = new DefaultAzureCredentialBuilder (). build();
218- ContainerRepository containerRepository = new ContainerRegistryClientBuilder ()
219- .endpoint(endpoint)
220- .credential(credential)
221- .buildClient()
222- .getRepository(repositoryName);
223- try {
224- containerRepository. getProperties();
225- } catch (HttpResponseException exception) {
226- // Do something with the exception.
227- }
217+ public void getPropertiesThrows() {
218+ DefaultAzureCredential credential = new DefaultAzureCredentialBuilder (). build();
219+ ContainerRepository containerRepository = new ContainerRegistryClientBuilder ()
220+ .endpoint(endpoint)
221+ .credential(credential)
222+ .buildClient()
223+ .getRepository(repositoryName);
224+ try {
225+ containerRepository. getProperties();
226+ } catch (HttpResponseException exception) {
227+ // Do something with the exception.
228+ }
228229```
229230
230231## Next steps
0 commit comments