Skip to content

Commit 0c2dc25

Browse files
BalashivaramBalashivaram Ganesan
andauthored
Updated existing parameter "identity" to type string[] to configure Multiple MSIs (Azure#9782)
* Added new Parameter Identities to configure Multiple MSIs * honor both identity and identities parameters to build policy json * Fixed style failures * Remove unused imports * Revert changes related to identity type * Commit recorded result for tests * Changed id to identity_id * Updated test and updated history, setup file * Update the identity parameter from type string to string[] * Updated Identity parameter type from string to string[] * Fix identation * Applied copilot suggestions * Added live only parameter to tests --------- Co-authored-by: Balashivaram Ganesan <bganesan@microsoft.com>
1 parent c0df1fd commit 0c2dc25

8 files changed

Lines changed: 1629 additions & 14 deletions

File tree

src/azure-firewall/HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Release History
44
===============
55

6+
2.2.0
7+
++++++
8+
* `az network firewall policy create` : Updated parameter `--identity` to support multiple MSIs
9+
* `az network firewall policy update` : Updated parameter `--identity` to support multiple MSIs
10+
611
2.1.1
712
++++++
813
* Update AzureFirewall model to support extended location.

src/azure-firewall/azext_firewall/aaz/latest/network/firewall/policy/_create.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
141141
)
142142
explicit_proxy.pac_file = AAZStrArg(
143143
options=["pac-file"],
144-
help="SAS URL for PAC file.",
144+
help="URL for PAC file.",
145145
)
146146
explicit_proxy.pac_file_port = AAZIntArg(
147147
options=["pac-file-port"],

src/azure-firewall/azext_firewall/aaz/latest/network/firewall/policy/_update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
146146
)
147147
explicit_proxy.pac_file = AAZStrArg(
148148
options=["pac-file"],
149-
help="SAS URL for PAC file.",
149+
help="URL for PAC file.",
150150
nullable=True,
151151
)
152152
explicit_proxy.pac_file_port = AAZIntArg(

src/azure-firewall/azext_firewall/custom.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
172172
args_schema.pac_file = AAZStrArg(
173173
options=["--pac-file"],
174174
arg_group="Explicit Proxy",
175-
help="SAS URL for PAC file.",
175+
help="URL for PAC file.",
176176
)
177177
args_schema.m_public_ip._fmt = AAZResourceIdArgFormat(
178178
template="/subscriptions/{subscription}/resourceGroups/{resource_group}/providers/Microsoft.Network"
@@ -890,11 +890,13 @@ def _output(self, *args, **kwargs):
890890
class AzureFirewallPoliciesCreate(_AzureFirewallPoliciesCreate):
891891
@classmethod
892892
def _build_arguments_schema(cls, *args, **kwargs):
893-
from azure.cli.core.aaz import AAZResourceIdArg, AAZResourceIdArgFormat
893+
from azure.cli.core.aaz import AAZListArg, AAZResourceIdArg, AAZResourceIdArgFormat
894894
args_schema = super()._build_arguments_schema(*args, **kwargs)
895-
args_schema.identity = AAZResourceIdArg(
895+
args_schema.identity = AAZListArg(
896896
options=['--identity'],
897-
help="Name or ID of the ManagedIdentity Resource.",
897+
help="Name or Space-separated list of ManagedIdentity Resource IDs.",
898+
)
899+
args_schema.identity.Element = AAZResourceIdArg(
898900
fmt=AAZResourceIdArgFormat(
899901
template="/subscriptions/{subscription}/resourceGroups/{resource_group}/providers/"
900902
"Microsoft.ManagedIdentity/userAssignedIdentities/{}",
@@ -913,7 +915,9 @@ def pre_operations(self):
913915
args = self.ctx.args
914916
if has_value(args.identity):
915917
args.identity_type = "UserAssigned"
916-
args.user_assigned_identities = {args.identity.to_serialized_data(): {}}
918+
identities = []
919+
identities.extend([identity_id.to_serialized_data() for identity_id in args.identity])
920+
args.user_assigned_identities = {identity_id: {} for identity_id in identities}
917921

918922
if has_value(args.dns_servers):
919923
if not has_value(args.enable_dns_proxy):
@@ -923,14 +927,16 @@ def pre_operations(self):
923927
class AzureFirewallPoliciesUpdate(_AzureFirewallPoliciesUpdate):
924928
@classmethod
925929
def _build_arguments_schema(cls, *args, **kwargs):
926-
from azure.cli.core.aaz import AAZResourceIdArg, AAZResourceIdArgFormat
930+
from azure.cli.core.aaz import AAZResourceIdArg, AAZResourceIdArgFormat, AAZListArg
927931
args_schema = super()._build_arguments_schema(*args, **kwargs)
928-
args_schema.identity = AAZResourceIdArg(
932+
args_schema.identity = AAZListArg(
929933
options=['--identity'],
930-
help="Name or ID of the ManagedIdentity Resource.",
934+
help="Name or Space-separated list of ManagedIdentity Resource IDs.",
935+
)
936+
args_schema.identity.Element = AAZResourceIdArg(
931937
fmt=AAZResourceIdArgFormat(
932938
template="/subscriptions/{subscription}/resourceGroups/{resource_group}/providers/"
933-
"Microsoft.ManagedIdentity/userAssignedIdentities/{}",
939+
"Microsoft.ManagedIdentity/userAssignedIdentities/{}",
934940
)
935941
)
936942
args_schema.identity_type._registered = False
@@ -941,9 +947,12 @@ def _build_arguments_schema(cls, *args, **kwargs):
941947

942948
def pre_operations(self):
943949
args = self.ctx.args
950+
944951
if has_value(args.identity):
945952
args.identity_type = "UserAssigned"
946-
args.user_assigned_identities = {args.identity.to_serialized_data(): {}}
953+
identities = []
954+
identities.extend([identity_id.to_serialized_data() for identity_id in args.identity])
955+
args.user_assigned_identities = {identity_id: {} for identity_id in identities}
947956
elif args.sku == 'Premium':
948957
args.identity_type = "None"
949958
args.user_assigned_identities = None

0 commit comments

Comments
 (0)