From 241dd0d53dc61dbee9201b69211498deccd7b829 Mon Sep 17 00:00:00 2001 From: Aviral Takkar Date: Fri, 27 Mar 2026 20:46:52 +0000 Subject: [PATCH] feat(acr): add --endpoint-protocol parameter to az acr update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for configuring the endpoint protocol (IPv4 and/or IPv6) on Azure Container Registries via az acr update. Changes: - Add --endpoint-protocol parameter with enum values IPv4, IPv4AndIPv6 - Set instance.endpoint_protocol in acr_update_custom() when provided - Add help text example for updating endpoint protocol - Add test_acr_with_dual_stack_endpoints scenario test Requires azure-mgmt-containerregistry >= 15.1.0b1 with API version 2026-01-01-preview which includes the EndpointProtocol property on the Registry model. Validated on dogfood registry srcregistryaue (Australia East): - az acr update --endpoint-protocol IPv4AndIPv6 → success - az acr update --endpoint-protocol IPv4 → success Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/azure-cli/azure/cli/command_modules/acr/_help.py | 3 +++ .../azure/cli/command_modules/acr/_params.py | 1 + .../azure/cli/command_modules/acr/custom.py | 6 +++++- .../acr/tests/latest/test_acr_commands.py | 12 ++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/azure-cli/azure/cli/command_modules/acr/_help.py b/src/azure-cli/azure/cli/command_modules/acr/_help.py index e3e3907a5bc..ff4f8b5b0fc 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/_help.py +++ b/src/azure-cli/azure/cli/command_modules/acr/_help.py @@ -1514,6 +1514,9 @@ - name: Turn on ABAC-based Repository Permission on an existing registry. text: > az acr update -n myregistry --role-assignment-mode rbac-abac + - name: Update the endpoint protocol for an Azure Container Registry. + text: > + az acr update -n myregistry --endpoint-protocol IPv4AndIPv6 """ helps['acr webhook'] = """ diff --git a/src/azure-cli/azure/cli/command_modules/acr/_params.py b/src/azure-cli/azure/cli/command_modules/acr/_params.py index 5d4a4d68af6..198637f54fe 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/_params.py +++ b/src/azure-cli/azure/cli/command_modules/acr/_params.py @@ -131,6 +131,7 @@ def load_arguments(self, _): # pylint: disable=too-many-statements with self.argument_context('acr update', arg_group='Network Rule') as c: c.argument('data_endpoint_enabled', get_three_state_flag(), help="Enable dedicated data endpoint for client firewall configuration") + c.argument('endpoint_protocol', arg_type=get_enum_type(['IPv4', 'IPv4AndIPv6']), options_list=['--endpoint-protocol'], help="The endpoint protocol (IPv4 and/or IPv6) for the registry.") with self.argument_context('acr update') as c: c.argument('anonymous_pull_enabled', get_three_state_flag(), help="Enable registry-wide pull from unauthenticated clients") diff --git a/src/azure-cli/azure/cli/command_modules/acr/custom.py b/src/azure-cli/azure/cli/command_modules/acr/custom.py index a04ca43b904..7a2f861828a 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/custom.py +++ b/src/azure-cli/azure/cli/command_modules/acr/custom.py @@ -151,7 +151,8 @@ def acr_update_custom(cmd, allow_exports=None, tags=None, allow_metadata_search=None, - role_assignment_mode=None): + role_assignment_mode=None, + endpoint_protocol=None): if sku is not None: Sku = cmd.get_models('Sku') instance.sku = Sku(name=sku) @@ -180,6 +181,9 @@ def acr_update_custom(cmd, if role_assignment_mode is not None: _configure_role_assignment_mode(cmd, instance, role_assignment_mode) + if endpoint_protocol is not None: + instance.endpoint_protocol = endpoint_protocol + _handle_network_bypass(cmd, instance, allow_trusted_services) _handle_export_policy(cmd, instance, allow_exports) diff --git a/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_commands.py b/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_commands.py index 229f124b687..09154506360 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_commands.py +++ b/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_commands.py @@ -795,6 +795,18 @@ def test_acr_with_anonymous_pull(self, resource_group, resource_group_location): self.cmd('acr update --name {registry_name} --resource-group {rg} --anonymous-pull-enabled false', checks=[self.check('anonymousPullEnabled', False)]) + @ResourceGroupPreparer() + def test_acr_with_dual_stack_endpoints(self, resource_group, resource_group_location): + self.kwargs.update({ + 'registry_name': self.create_random_name('testreg', 20) + }) + self.cmd('acr create --name {registry_name} --resource-group {rg} --sku premium -l eastus', + checks=[self.check('endpointProtocol', 'IPv4')]) + self.cmd('acr update --name {registry_name} --resource-group {rg} --endpoint-protocol IPv4AndIPv6', + checks=[self.check('endpointProtocol', 'IPv4AndIPv6')]) + self.cmd('acr update --name {registry_name} --resource-group {rg} --endpoint-protocol IPv4', + checks=[self.check('endpointProtocol', 'IPv4')]) + @ResourceGroupPreparer() @live_only() def test_acr_create_invalid_name(self, resource_group):