Skip to content

Commit 922d0bb

Browse files
authored
Fixed for Ability to create Container Registry with zone redundancy (#38588)
* Fixed for Ability to create Container Registry with zone redundancy (issue#38488)
1 parent ad477de commit 922d0bb

File tree

4 files changed

+67
-1
lines changed

4 files changed

+67
-1
lines changed

sdk/resourcemanager/azure-resourcemanager-containerregistry/assets.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "java",
44
"TagPrefix": "java/resourcemanager/azure-resourcemanager-containerregistry",
5-
"Tag": "java/resourcemanager/azure-resourcemanager-containerregistry_1a4bd3c103"
5+
"Tag": "java/resourcemanager/azure-resourcemanager-containerregistry_c7a0288b18"
66
}

sdk/resourcemanager/azure-resourcemanager-containerregistry/src/main/java/com/azure/resourcemanager/containerregistry/implementation/RegistryImpl.java

+14
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.azure.resourcemanager.containerregistry.models.SkuName;
3030
import com.azure.resourcemanager.containerregistry.models.SourceUploadDefinition;
3131
import com.azure.resourcemanager.containerregistry.models.WebhookOperations;
32+
import com.azure.resourcemanager.containerregistry.models.ZoneRedundancy;
3233
import com.azure.resourcemanager.resources.fluentcore.arm.models.PrivateEndpoint;
3334
import com.azure.resourcemanager.resources.fluentcore.arm.models.PrivateEndpointConnection;
3435
import com.azure.resourcemanager.resources.fluentcore.arm.models.PrivateEndpointConnectionProvisioningState;
@@ -224,6 +225,11 @@ public boolean isDedicatedDataEndpointsEnabled() {
224225
return ResourceManagerUtils.toPrimitiveBoolean(this.innerModel().dataEndpointEnabled());
225226
}
226227

228+
@Override
229+
public boolean isZoneRedundancyEnabled() {
230+
return !Objects.isNull(this.innerModel().zoneRedundancy()) && ZoneRedundancy.ENABLED.equals(this.innerModel().zoneRedundancy());
231+
}
232+
227233
@Override
228234
public List<String> dedicatedDataEndpointsHostNames() {
229235
return this.innerModel().dataEndpointHostNames() == null
@@ -453,6 +459,14 @@ public PagedFlux<PrivateLinkResource> listPrivateLinkResourcesAsync() {
453459
.mapPage(PrivateLinkResourceImpl::new);
454460
}
455461

462+
@Override
463+
public RegistryImpl withZoneRedundancy() {
464+
if (isInCreateMode()) {
465+
this.innerModel().withZoneRedundancy(ZoneRedundancy.ENABLED);
466+
}
467+
return this;
468+
}
469+
456470
private static final class PrivateLinkResourceImpl implements PrivateLinkResource {
457471
private final PrivateLinkResourceInner innerModel;
458472

sdk/resourcemanager/azure-resourcemanager-containerregistry/src/main/java/com/azure/resourcemanager/containerregistry/models/Registry.java

+19
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ public interface Registry
106106
/** @return whether the container registries dedicated data endpoints can be accessed from public network */
107107
boolean isDedicatedDataEndpointsEnabled();
108108

109+
/** @return Whether or not zone redundancy is enabled for this container registry */
110+
boolean isZoneRedundancyEnabled();
111+
109112
/** @return list of host names that will serve data when isDedicatedDataEndpointsEnabled is true */
110113
List<String> dedicatedDataEndpointsHostNames();
111114

@@ -239,6 +242,21 @@ interface WithDedicatedDataEndpoints {
239242
WithCreate enableDedicatedDataEndpoints();
240243
}
241244

245+
/**
246+
* The stage of the container registry definition allowing to configure Zone Redundancy.
247+
*/
248+
interface WithZoneRedundancy {
249+
/**
250+
* Enables zone redundancy for the container registry.
251+
*
252+
* @return the next stage of the definition
253+
* @see <a href="https://learn.microsoft.com/en-us/azure/container-registry/zone-redundancy">
254+
* Enable zone redundancy
255+
* </a>
256+
*/
257+
WithCreate withZoneRedundancy();
258+
}
259+
242260
/**
243261
* The stage of the definition which contains all the minimum required inputs for the resource to be created,
244262
* but also allows for any other optional settings to be specified.
@@ -249,6 +267,7 @@ interface WithCreate
249267
WithWebhook,
250268
WithPublicNetworkAccess,
251269
WithDedicatedDataEndpoints,
270+
WithZoneRedundancy,
252271
Resource.DefinitionWithTags<WithCreate> {
253272
}
254273
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.resourcemanager.containerregistry;
5+
6+
import com.azure.core.management.Region;
7+
import com.azure.resourcemanager.containerregistry.models.Registry;
8+
import org.junit.jupiter.api.Assertions;
9+
import org.junit.jupiter.api.Test;
10+
11+
public class RegistryOperationsTests extends RegistryTest {
12+
13+
@Override
14+
protected void cleanUpResources() {
15+
resourceManager.resourceGroups().beginDeleteByName(rgName);
16+
}
17+
18+
@Test
19+
public void canCreateContainerRegisterWithZoneRedundancy() {
20+
final String acrName = generateRandomResourceName("acr", 10);
21+
Registry registry =
22+
registryManager
23+
.containerRegistries()
24+
.define(acrName)
25+
.withRegion(Region.US_EAST)
26+
.withNewResourceGroup(rgName)
27+
.withPremiumSku()
28+
.withRegistryNameAsAdminUser()
29+
.withZoneRedundancy()
30+
.create();
31+
Assertions.assertTrue(registry.isZoneRedundancyEnabled());
32+
}
33+
}

0 commit comments

Comments
 (0)