@@ -220,6 +220,81 @@ def test_nw_flow_log_create_vnetfl_with_record_types(self, resource_group, resou
220220 self .check ('retentionPolicy.enabled' , False ),
221221 ])
222222
223+
224+ @ResourceGroupPreparer (name_prefix = 'test_nw_flow_log_' , location = 'centraluseuap' )
225+ @StorageAccountPreparer (name_prefix = 'testflowlog' , location = 'centraluseuap' , kind = 'StorageV2' )
226+ def test_nw_flow_log_update_vnetfl_with_record_types (self , resource_group , resource_group_location , storage_account ):
227+ self .kwargs .update ({
228+ 'rg' : resource_group ,
229+ 'location' : resource_group_location ,
230+ 'storage_account' : storage_account ,
231+ 'vnet' : 'vnet1' ,
232+ 'subnet' : 'subnet1' ,
233+ 'nic' : 'nic1' ,
234+ 'watcher_rg' : 'NetworkWatcherRG' ,
235+ 'watcher_name' : 'NetworkWatcher_{}' .format (resource_group_location ),
236+ 'flow_log' : 'flow_log_test_update_rt' ,
237+ 'workspace' : self .create_random_name ('clitest' , 20 ),
238+ 'record_types' : 'B,E'
239+ })
240+
241+ # Prepare target resources
242+ self .cmd ('network vnet create -g {rg} -n {vnet}' )
243+ self .cmd ('network vnet subnet create -g {rg} --vnet-name {vnet} -n {subnet} --address-prefix 10.0.0.0/24' )
244+ self .cmd ('network nic create -g {rg} -n {nic} --vnet-name {vnet} --subnet {subnet}' )
245+
246+ # Prepare workspace (use eastus for LA workspace)
247+ workspace = self .cmd (
248+ 'monitor log-analytics workspace create '
249+ '--resource-group {rg} '
250+ '--location eastus '
251+ '--workspace-name {workspace} '
252+ ).get_output_in_json ()
253+ self .kwargs .update ({'workspace_id' : workspace ['id' ]})
254+
255+ # Create flow log for VNet (no record-types initially)
256+ self .cmd (
257+ 'network watcher flow-log create '
258+ '--location {location} '
259+ '--resource-group {rg} '
260+ '--vnet {vnet} '
261+ '--storage-account {storage_account} '
262+ '--workspace {workspace_id} '
263+ '--name {flow_log} '
264+ )
265+
266+ # Baseline verification
267+ res1 = self .cmd (
268+ 'network watcher flow-log show --location {location} --name {flow_log}'
269+ ).get_output_in_json ()
270+ self .assertEqual (res1 ['name' ], self .kwargs ['flow_log' ])
271+ self .assertEqual (res1 ['enabled' ], True )
272+ self .assertTrue (res1 ['targetResourceId' ].endswith (self .kwargs ['vnet' ]))
273+
274+ # ---- Update: set record types to B,E on the same VNet target ----
275+ res2 = self .cmd (
276+ 'network watcher flow-log update '
277+ '--location {location} '
278+ '--resource-group {rg} '
279+ '--vnet {vnet} '
280+ '--name {flow_log} '
281+ '--record-types {record_types} '
282+ ).get_output_in_json ()
283+
284+ self .assertEqual (res2 ['name' ], self .kwargs ['flow_log' ])
285+ self .assertEqual (res2 ['enabled' ], True )
286+ self .assertTrue (res2 ['targetResourceId' ].endswith (self .kwargs ['vnet' ]))
287+ self .assertEqual (res2 ['recordTypes' ], self .kwargs ['record_types' ])
288+ # Retention defaults remain unless explicitly changed
289+ self .assertEqual (res2 ['retentionPolicy' ]['enabled' ], False )
290+ self .assertEqual (res2 ['retentionPolicy' ]['days' ], 0 )
291+
292+ # Show again and validate persisted update
293+ self .cmd ('network watcher flow-log show --location {location} --name {flow_log}' , checks = [
294+ self .check ('name' , self .kwargs ['flow_log' ]),
295+ self .check ('recordTypes' , '{record_types}' )
296+ ])
297+
223298 @ResourceGroupPreparer (name_prefix = 'test_nw_flow_log_' , location = 'centraluseuap' )
224299 @StorageAccountPreparer (name_prefix = 'testflowlog' , location = 'centraluseuap' , kind = 'StorageV2' )
225300 def test_nw_flow_log_create_vnetflWithManagedIdentity (self , resource_group , resource_group_location , storage_account ):
0 commit comments