Skip to content

Commit 104cb2e

Browse files
riddhinilawarRiddhi NilawarCopilot
authored
[Network] az network watcher flow-log: Add --record-types parameter (#32490)
Co-authored-by: Riddhi Nilawar <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent c8ef274 commit 104cb2e

File tree

6 files changed

+253
-18
lines changed

6 files changed

+253
-18
lines changed

src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/watcher/flow_log/_create.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ class Create(AAZCommand):
4343
4444
:example: Create or update flow log
4545
az network watcher flow-log create --location westus --resource-group MtRGContainingVNet --name MyVNetName-flowlog --vnet MyVNetName --storage-account MyStorageAccountName --filtering-criteria "dstip=20.252.145.59 || DstPort=443"
46+
47+
:example: Create flow log with recordtypes filtering
48+
az network watcher flow-log create --resource-group rg1 --network-watcher-name nw1 --name fl --location centraluseuap --target-resource-id /subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/desmondcentral-nsg --storage-account /subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Storage/storageAccounts/nwtest1mgvbfmqsigdxe --filtering-criteria srcIP=158.255.7.8 || dstPort=56891 --record-types B,E --enabled True --format JSON --log-version 1 --identity "{type:UserAssigned,user-assigned-identities:{/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1:{}}}"
4649
"""
4750

4851
_aaz_info = {
49-
"version": "2024-03-01",
52+
"version": "2025-03-01",
5053
"resources": [
51-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkwatchers/{}/flowlogs/{}", "2024-03-01"],
54+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkwatchers/{}/flowlogs/{}", "2025-03-01"],
5255
]
5356
}
5457

@@ -130,17 +133,29 @@ def _build_arguments_schema(cls, *args, **kwargs):
130133
)
131134

132135
identity = cls._args_schema.identity
133-
136+
identity.mi_system_assigned = AAZStrArg(
137+
options=["system-assigned", "mi-system-assigned"],
138+
help="Set the system managed identity.",
139+
blank="True",
140+
)
134141
identity.type = AAZStrArg(
135142
options=["type"],
136143
help="The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine.",
137144
enum={"None": "None", "SystemAssigned": "SystemAssigned", "SystemAssigned, UserAssigned": "SystemAssigned, UserAssigned", "UserAssigned": "UserAssigned"},
138145
)
146+
identity.mi_user_assigned = AAZListArg(
147+
options=["user-assigned", "mi-user-assigned"],
148+
help="Set the user managed identities.",
149+
blank=[],
150+
)
139151
identity.user_assigned_identities = AAZDictArg(
140152
options=["user-assigned-identities"],
141153
help="The list of user identities associated with resource. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.",
142154
)
143155

156+
mi_user_assigned = cls._args_schema.identity.mi_user_assigned
157+
mi_user_assigned.Element = AAZStrArg()
158+
144159
user_assigned_identities = cls._args_schema.identity.user_assigned_identities
145160
user_assigned_identities.Element = AAZObjectArg(
146161
blank={},
@@ -159,6 +174,11 @@ def _build_arguments_schema(cls, *args, **kwargs):
159174
arg_group="Properties",
160175
help="Parameters that define the configuration of traffic analytics.",
161176
)
177+
_args_schema.record_types = AAZStrArg(
178+
options=["--record-types"],
179+
arg_group="Properties",
180+
help="Optional field to filter network traffic logs based on flow states. Value of this field could be any comma separated combination string of letters B,C,E or D. B represents Begin, when a flow is created. C represents Continue for an ongoing flow generated at every five-minute interval. E represents End, when a flow is terminated. D represents Deny, when a flow is denied. If not specified, all network traffic will be logged.",
181+
)
162182
_args_schema.retention_policy = AAZObjectArg(
163183
options=["--retention-policy"],
164184
arg_group="Properties",
@@ -290,7 +310,7 @@ def url_parameters(self):
290310
def query_parameters(self):
291311
parameters = {
292312
**self.serialize_query_param(
293-
"api-version", "2024-03-01",
313+
"api-version", "2025-03-01",
294314
required=True,
295315
),
296316
}
@@ -315,7 +335,7 @@ def content(self):
315335
typ=AAZObjectType,
316336
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
317337
)
318-
_builder.set_prop("identity", AAZObjectType, ".identity")
338+
_builder.set_prop("identity", AAZIdentityObjectType, ".identity")
319339
_builder.set_prop("location", AAZStrType, ".location")
320340
_builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}})
321341
_builder.set_prop("tags", AAZDictType, ".tags")
@@ -324,18 +344,24 @@ def content(self):
324344
if identity is not None:
325345
identity.set_prop("type", AAZStrType, ".type")
326346
identity.set_prop("userAssignedIdentities", AAZDictType, ".user_assigned_identities")
347+
identity.set_prop("userAssigned", AAZListType, ".mi_user_assigned", typ_kwargs={"flags": {"action": "create"}})
348+
identity.set_prop("systemAssigned", AAZStrType, ".mi_system_assigned", typ_kwargs={"flags": {"action": "create"}})
327349

328350
user_assigned_identities = _builder.get(".identity.userAssignedIdentities")
329351
if user_assigned_identities is not None:
330352
user_assigned_identities.set_elements(AAZObjectType, ".")
331353

354+
user_assigned = _builder.get(".identity.userAssigned")
355+
if user_assigned is not None:
356+
user_assigned.set_elements(AAZStrType, ".")
332357

333358
properties = _builder.get(".properties")
334359
if properties is not None:
335360
properties.set_prop("enabled", AAZBoolType, ".enabled")
336361
properties.set_prop("enabledFilteringCriteria", AAZStrType, ".filtering_criteria")
337362
properties.set_prop("flowAnalyticsConfiguration", AAZObjectType, ".flow_analytics_configuration")
338363
properties.set_prop("format", AAZObjectType)
364+
properties.set_prop("recordTypes", AAZStrType, ".record_types")
339365
properties.set_prop("retentionPolicy", AAZObjectType, ".retention_policy")
340366
properties.set_prop("storageId", AAZStrType, ".storage_account", typ_kwargs={"flags": {"required": True}})
341367
properties.set_prop("targetResourceId", AAZStrType, ".target_resource_id", typ_kwargs={"flags": {"required": True}})
@@ -390,7 +416,7 @@ def _build_schema_on_200_201(cls):
390416
flags={"read_only": True},
391417
)
392418
_schema_on_200_201.id = AAZStrType()
393-
_schema_on_200_201.identity = AAZObjectType()
419+
_schema_on_200_201.identity = AAZIdentityObjectType()
394420
_schema_on_200_201.location = AAZStrType()
395421
_schema_on_200_201.name = AAZStrType(
396422
flags={"read_only": True},
@@ -443,6 +469,9 @@ def _build_schema_on_200_201(cls):
443469
serialized_name="provisioningState",
444470
flags={"read_only": True},
445471
)
472+
properties.record_types = AAZStrType(
473+
serialized_name="recordTypes",
474+
)
446475
properties.retention_policy = AAZObjectType(
447476
serialized_name="retentionPolicy",
448477
)

src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/watcher/flow_log/_delete.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class Delete(AAZCommand):
2222
"""
2323

2424
_aaz_info = {
25-
"version": "2024-03-01",
25+
"version": "2025-03-01",
2626
"resources": [
27-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkwatchers/{}/flowlogs/{}", "2024-03-01"],
27+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkwatchers/{}/flowlogs/{}", "2025-03-01"],
2828
]
2929
}
3030

@@ -152,7 +152,7 @@ def url_parameters(self):
152152
def query_parameters(self):
153153
parameters = {
154154
**self.serialize_query_param(
155-
"api-version", "2024-03-01",
155+
"api-version", "2025-03-01",
156156
required=True,
157157
),
158158
}

src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/watcher/flow_log/_show.py

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class Show(AAZCommand):
2525
"""
2626

2727
_aaz_info = {
28-
"version": "2024-03-01",
28+
"version": "2025-03-01",
2929
"resources": [
30-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkwatchers/{}/flowlogs/{}", "2024-03-01"],
30+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkwatchers/{}/flowlogs/{}", "2025-03-01"],
3131
]
3232
}
3333

@@ -133,7 +133,7 @@ def url_parameters(self):
133133
def query_parameters(self):
134134
parameters = {
135135
**self.serialize_query_param(
136-
"api-version", "2024-03-01",
136+
"api-version", "2025-03-01",
137137
required=True,
138138
),
139139
}
@@ -170,6 +170,7 @@ def _build_schema_on_200(cls):
170170
flags={"read_only": True},
171171
)
172172
_schema_on_200.id = AAZStrType()
173+
_schema_on_200.identity = AAZIdentityObjectType()
173174
_schema_on_200.location = AAZStrType()
174175
_schema_on_200.name = AAZStrType(
175176
flags={"read_only": True},
@@ -182,6 +183,33 @@ def _build_schema_on_200(cls):
182183
flags={"read_only": True},
183184
)
184185

186+
identity = cls._schema_on_200.identity
187+
identity.principal_id = AAZStrType(
188+
serialized_name="principalId",
189+
flags={"read_only": True},
190+
)
191+
identity.tenant_id = AAZStrType(
192+
serialized_name="tenantId",
193+
flags={"read_only": True},
194+
)
195+
identity.type = AAZStrType()
196+
identity.user_assigned_identities = AAZDictType(
197+
serialized_name="userAssignedIdentities",
198+
)
199+
200+
user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities
201+
user_assigned_identities.Element = AAZObjectType()
202+
203+
_element = cls._schema_on_200.identity.user_assigned_identities.Element
204+
_element.client_id = AAZStrType(
205+
serialized_name="clientId",
206+
flags={"read_only": True},
207+
)
208+
_element.principal_id = AAZStrType(
209+
serialized_name="principalId",
210+
flags={"read_only": True},
211+
)
212+
185213
properties = cls._schema_on_200.properties
186214
properties.enabled = AAZBoolType()
187215
properties.enabled_filtering_criteria = AAZStrType(
@@ -195,6 +223,9 @@ def _build_schema_on_200(cls):
195223
serialized_name="provisioningState",
196224
flags={"read_only": True},
197225
)
226+
properties.record_types = AAZStrType(
227+
serialized_name="recordTypes",
228+
)
198229
properties.retention_policy = AAZObjectType(
199230
serialized_name="retentionPolicy",
200231
)

src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/watcher/flow_log/_update.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ class Update(AAZCommand):
3737
3838
:example: Update Workspace on another resource group
3939
az network watcher flow-log update --location westus --resource-group MyAnotherResourceGroup --name MyFlowLog --workspace MyAnotherLogAnalyticWorkspace
40+
41+
:example: Update flowlog with recordtypes filtering
42+
az network watcher flow-log update --resource-group rg1 --network-watcher-name nw1 --name fl --location centraluseuap --target-resource-id /subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/desmondcentral-nsg --storage-account /subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Storage/storageAccounts/nwtest1mgvbfmqsigdxe --filtering-criteria srcIP=158.255.7.8 || dstPort=56891 --record-types B,E --enabled True --format JSON --log-version 1 --identity "{type:UserAssigned,user-assigned-identities:{/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1:{}}}"
4043
"""
4144

4245
_aaz_info = {
43-
"version": "2024-03-01",
46+
"version": "2025-03-01",
4447
"resources": [
45-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkwatchers/{}/flowlogs/{}", "2024-03-01"],
48+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkwatchers/{}/flowlogs/{}", "2025-03-01"],
4649
]
4750
}
4851

@@ -165,6 +168,12 @@ def _build_arguments_schema(cls, *args, **kwargs):
165168
help="Parameters that define the configuration of traffic analytics.",
166169
nullable=True,
167170
)
171+
_args_schema.record_types = AAZStrArg(
172+
options=["--record-types"],
173+
arg_group="Properties",
174+
help="Optional field to filter network traffic logs based on flow states. Value of this field could be any comma separated combination string of letters B,C,E or D. B represents Begin, when a flow is created. C represents Continue for an ongoing flow generated at every five-minute interval. E represents End, when a flow is terminated. D represents Deny, when a flow is denied. If not specified, all network traffic will be logged.",
175+
nullable=True,
176+
)
168177
_args_schema.retention_policy = AAZObjectArg(
169178
options=["--retention-policy"],
170179
arg_group="Properties",
@@ -299,7 +308,7 @@ def url_parameters(self):
299308
def query_parameters(self):
300309
parameters = {
301310
**self.serialize_query_param(
302-
"api-version", "2024-03-01",
311+
"api-version", "2025-03-01",
303312
required=True,
304313
),
305314
}
@@ -402,7 +411,7 @@ def url_parameters(self):
402411
def query_parameters(self):
403412
parameters = {
404413
**self.serialize_query_param(
405-
"api-version", "2024-03-01",
414+
"api-version", "2025-03-01",
406415
required=True,
407416
),
408417
}
@@ -480,6 +489,7 @@ def _update_instance(self, instance):
480489
properties.set_prop("enabledFilteringCriteria", AAZStrType, ".filtering_criteria")
481490
properties.set_prop("flowAnalyticsConfiguration", AAZObjectType, ".flow_analytics_configuration")
482491
properties.set_prop("format", AAZObjectType)
492+
properties.set_prop("recordTypes", AAZStrType, ".record_types")
483493
properties.set_prop("retentionPolicy", AAZObjectType, ".retention_policy")
484494
properties.set_prop("storageId", AAZStrType, ".storage_account", typ_kwargs={"flags": {"required": True}})
485495
properties.set_prop("targetResourceId", AAZStrType, ".target_resource_id", typ_kwargs={"flags": {"required": True}})
@@ -599,6 +609,9 @@ def _build_schema_flow_log_read(cls, _schema):
599609
serialized_name="provisioningState",
600610
flags={"read_only": True},
601611
)
612+
properties.record_types = AAZStrType(
613+
serialized_name="recordTypes",
614+
)
602615
properties.retention_policy = AAZObjectType(
603616
serialized_name="retentionPolicy",
604617
)

src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/watcher/flow_log/_wait.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Wait(AAZWaitCommand):
2020

2121
_aaz_info = {
2222
"resources": [
23-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkwatchers/{}/flowlogs/{}", "2024-03-01"],
23+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networkwatchers/{}/flowlogs/{}", "2025-03-01"],
2424
]
2525
}
2626

@@ -126,7 +126,7 @@ def url_parameters(self):
126126
def query_parameters(self):
127127
parameters = {
128128
**self.serialize_query_param(
129-
"api-version", "2024-03-01",
129+
"api-version", "2025-03-01",
130130
required=True,
131131
),
132132
}
@@ -163,6 +163,7 @@ def _build_schema_on_200(cls):
163163
flags={"read_only": True},
164164
)
165165
_schema_on_200.id = AAZStrType()
166+
_schema_on_200.identity = AAZIdentityObjectType()
166167
_schema_on_200.location = AAZStrType()
167168
_schema_on_200.name = AAZStrType(
168169
flags={"read_only": True},
@@ -175,6 +176,33 @@ def _build_schema_on_200(cls):
175176
flags={"read_only": True},
176177
)
177178

179+
identity = cls._schema_on_200.identity
180+
identity.principal_id = AAZStrType(
181+
serialized_name="principalId",
182+
flags={"read_only": True},
183+
)
184+
identity.tenant_id = AAZStrType(
185+
serialized_name="tenantId",
186+
flags={"read_only": True},
187+
)
188+
identity.type = AAZStrType()
189+
identity.user_assigned_identities = AAZDictType(
190+
serialized_name="userAssignedIdentities",
191+
)
192+
193+
user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities
194+
user_assigned_identities.Element = AAZObjectType()
195+
196+
_element = cls._schema_on_200.identity.user_assigned_identities.Element
197+
_element.client_id = AAZStrType(
198+
serialized_name="clientId",
199+
flags={"read_only": True},
200+
)
201+
_element.principal_id = AAZStrType(
202+
serialized_name="principalId",
203+
flags={"read_only": True},
204+
)
205+
178206
properties = cls._schema_on_200.properties
179207
properties.enabled = AAZBoolType()
180208
properties.enabled_filtering_criteria = AAZStrType(
@@ -188,6 +216,9 @@ def _build_schema_on_200(cls):
188216
serialized_name="provisioningState",
189217
flags={"read_only": True},
190218
)
219+
properties.record_types = AAZStrType(
220+
serialized_name="recordTypes",
221+
)
191222
properties.retention_policy = AAZObjectType(
192223
serialized_name="retentionPolicy",
193224
)

0 commit comments

Comments
 (0)