Skip to content

Commit 54697d5

Browse files
johnsonshiCopilot
andcommitted
az acr create: add --endpoint-protocol and --data-endpoint-enabled flags
Add support for --endpoint-protocol and --data-endpoint-enabled parameters on az acr create, complementing the existing support on az acr update. - --endpoint-protocol: Allows creating a registry with IPv4AndIPv6 (dual-stack) endpoint protocol. Requires --data-endpoint-enabled true. - --data-endpoint-enabled: Allows enabling dedicated data endpoints at registry creation time instead of requiring a separate update call. - Added help text examples showing combined usage. - Added unit tests for both new parameters. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f7f6f67 commit 54697d5

4 files changed

Lines changed: 45 additions & 4 deletions

File tree

src/azure-cli/azure/cli/command_modules/acr/_help.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@
185185
- name: Create a managed container registry with the Premium SKU and regional endpoints enabled.
186186
text: >
187187
az acr create -n myregistry -g MyResourceGroup --sku Premium --regional-endpoints enabled
188+
- name: Create a managed container registry with the Premium SKU and dual-stack (IPv4 and IPv6) endpoint protocol.
189+
text: >
190+
az acr create -n myregistry -g MyResourceGroup --sku Premium --data-endpoint-enabled true --endpoint-protocol IPv4AndIPv6
188191
"""
189192

190193
helps['acr credential'] = """

src/azure-cli/azure/cli/command_modules/acr/_params.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,10 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
132132
with self.argument_context('acr create') as c:
133133
c.argument('dnl_scope', options_list=['--dnl-scope'], help='Domain name label scope will add a hash to the resource name. The resulting login server name will be in the format `registryname`-`hash`.azurecr-io. Default is Unsecure.', is_preview=True, arg_type=get_enum_type(AutoGeneratedDomainNameLabelScope))
134134

135-
with self.argument_context('acr update', arg_group='Network Rule') as c:
136-
c.argument('data_endpoint_enabled', get_three_state_flag(), help="Enable dedicated data endpoint for client firewall configuration")
137-
c.argument('endpoint_protocol', arg_type=get_enum_type(['IPv4', 'IPv4AndIPv6']), options_list=['--endpoint-protocol'], is_preview=True, help="The endpoint protocol for the registry. Allowed values: IPv4, IPv4AndIPv6.")
135+
for scope in ['acr create', 'acr update']:
136+
with self.argument_context(scope, arg_group='Network Rule') as c:
137+
c.argument('data_endpoint_enabled', get_three_state_flag(), help="Enable dedicated data endpoint for client firewall configuration")
138+
c.argument('endpoint_protocol', arg_type=get_enum_type(['IPv4', 'IPv4AndIPv6']), options_list=['--endpoint-protocol'], is_preview=True, help="The endpoint protocol for the registry. Allowed values: IPv4, IPv4AndIPv6.")
138139

139140
with self.argument_context('acr update') as c:
140141
c.argument('anonymous_pull_enabled', get_three_state_flag(), help="Enable registry-wide pull from unauthenticated clients")

src/azure-cli/azure/cli/command_modules/acr/custom.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def acr_create(cmd,
7777
allow_metadata_search=None,
7878
dnl_scope=None,
7979
role_assignment_mode=None,
80-
regional_endpoints=None):
80+
regional_endpoints=None,
81+
data_endpoint_enabled=None,
82+
endpoint_protocol=None):
8183
if default_action and sku not in get_premium_sku(cmd):
8284
raise CLIError(NETWORK_RULE_NOT_SUPPORTED)
8385

@@ -114,6 +116,12 @@ def acr_create(cmd,
114116
if regional_endpoints is not None:
115117
_configure_regional_endpoints(cmd, registry, sku, regional_endpoints)
116118

119+
if data_endpoint_enabled is not None:
120+
registry.data_endpoint_enabled = data_endpoint_enabled
121+
122+
if endpoint_protocol is not None:
123+
registry.endpoint_protocol = endpoint_protocol
124+
117125
_handle_network_bypass(cmd, registry, allow_trusted_services)
118126
_handle_export_policy(cmd, registry, allow_exports)
119127

src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_commands.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,35 @@ def test_acr_with_dual_stack_endpoints(self, resource_group, resource_group_loca
811811
self.cmd('acr update --name {registry_name} --resource-group {rg} --endpoint-protocol IPv4',
812812
checks=[self.check('endpointProtocol', 'IPv4')])
813813

814+
@ResourceGroupPreparer()
815+
@live_only()
816+
def test_acr_create_with_dual_stack_endpoints(self, resource_group, resource_group_location):
817+
self.kwargs.update({
818+
'registry_name': self.create_random_name('testreg', 20)
819+
})
820+
self.cmd('acr create --name {registry_name} --resource-group {rg} --sku premium -l eastus '
821+
'--data-endpoint-enabled true --endpoint-protocol IPv4AndIPv6',
822+
checks=[self.check('endpointProtocol', 'IPv4AndIPv6'),
823+
self.check('dataEndpointEnabled', True)])
824+
self.cmd('acr update --name {registry_name} --resource-group {rg} --endpoint-protocol IPv4',
825+
checks=[self.check('endpointProtocol', 'IPv4')])
826+
self.cmd('acr update --name {registry_name} --resource-group {rg} --endpoint-protocol IPv4AndIPv6',
827+
checks=[self.check('endpointProtocol', 'IPv4AndIPv6')])
828+
829+
@ResourceGroupPreparer()
830+
@live_only()
831+
def test_acr_create_with_data_endpoint(self, resource_group, resource_group_location):
832+
self.kwargs.update({
833+
'registry_name': self.create_random_name('testreg', 20)
834+
})
835+
self.cmd('acr create --name {registry_name} --resource-group {rg} --sku premium -l eastus '
836+
'--data-endpoint-enabled true',
837+
checks=[self.check('dataEndpointEnabled', True)])
838+
self.cmd('acr update --name {registry_name} --resource-group {rg} --data-endpoint-enabled false',
839+
checks=[self.check('dataEndpointEnabled', False)])
840+
self.cmd('acr update --name {registry_name} --resource-group {rg} --data-endpoint-enabled true',
841+
checks=[self.check('dataEndpointEnabled', True)])
842+
814843
@ResourceGroupPreparer()
815844
@live_only()
816845
def test_acr_create_invalid_name(self, resource_group):

0 commit comments

Comments
 (0)