@@ -161,27 +161,29 @@ Use [New-AzNetworkWatcherFlowLog](/powershell/module/az.network/new-aznetworkwat
161
161
162
162
``` azurepowershell-interactive
163
163
# Place the virtual network configuration into a variable.
164
- $vnet = Get-AzVirtualNetwork -Name myVNet -ResourceGroupName myResourceGroup
164
+ $vnet = Get-AzVirtualNetwork -Name 'myVNet' -ResourceGroupName 'myResourceGroup'
165
+
165
166
# Place the storage account configuration into a variable.
166
- $storageAccount = Get-AzStorageAccount -Name myStorageAccount -ResourceGroupName myResourceGroup
167
+ $storageAccount = Get-AzStorageAccount -Name ' myStorageAccount' -ResourceGroupName ' myResourceGroup'
167
168
168
169
# Create a VNet flow log.
169
- New-AzNetworkWatcherFlowLog -Enabled $true -Name myVNetFlowLog -NetworkWatcherName NetworkWatcher_eastus -ResourceGroupName NetworkWatcherRG -StorageId $storageAccount.Id -TargetResourceId $vnet.Id -FormatVersion 2
170
+ New-AzNetworkWatcherFlowLog -Enabled $true -Name ' myVNetFlowLog' -NetworkWatcherName ' NetworkWatcher_eastus' -ResourceGroupName ' NetworkWatcherRG' -StorageId $storageAccount.Id -TargetResourceId $vnet.Id -FormatVersion 2
170
171
```
171
172
172
173
### Enable virtual network flow logs and traffic analytics
173
174
174
175
``` azurepowershell-interactive
175
176
# Place the virtual network configuration into a variable.
176
- $vnet = Get-AzVirtualNetwork -Name myVNet -ResourceGroupName myResourceGroup
177
+ $vnet = Get-AzVirtualNetwork -Name 'myVNet' -ResourceGroupName 'myResourceGroup'
178
+
177
179
# Place the storage account configuration into a variable.
178
- $storageAccount = Get-AzStorageAccount -Name myStorageAccount -ResourceGroupName myResourceGroup
180
+ $storageAccount = Get-AzStorageAccount -Name ' myStorageAccount' -ResourceGroupName ' myResourceGroup'
179
181
180
182
# Create a traffic analytics workspace and place its configuration into a variable.
181
- $workspace = New-AzOperationalInsightsWorkspace -Name myWorkspace -ResourceGroupName myResourceGroup -Location EastUS
183
+ $workspace = New-AzOperationalInsightsWorkspace -Name ' myWorkspace' -ResourceGroupName ' myResourceGroup' -Location ' EastUS'
182
184
183
185
# Create a VNet flow log.
184
- New-AzNetworkWatcherFlowLog -Enabled $true -Name myVNetFlowLog -NetworkWatcherName NetworkWatcher_eastus -ResourceGroupName NetworkWatcherRG -StorageId $storageAccount.Id -TargetResourceId $vnet.Id -FormatVersion 2 -EnableTrafficAnalytics -TrafficAnalyticsWorkspaceId $workspace.ResourceId -TrafficAnalyticsInterval 10
186
+ New-AzNetworkWatcherFlowLog -Enabled $true -Name ' myVNetFlowLog' -NetworkWatcherName ' NetworkWatcher_eastus' -ResourceGroupName ' NetworkWatcherRG' -StorageId $storageAccount.Id -TargetResourceId $vnet.Id -FormatVersion 2 -EnableTrafficAnalytics -TrafficAnalyticsWorkspaceId $workspace.ResourceId -TrafficAnalyticsInterval 10
185
187
```
186
188
187
189
# [ ** Azure CLI** ] ( #tab/cli )
@@ -192,12 +194,12 @@ Use [az network watcher flow-log create](/cli/azure/network/watcher/flow-log#az-
192
194
193
195
``` azurecli-interactive
194
196
# Create a VNet flow log.
195
- az network watcher flow-log create --location 'eastus' --resource-group 'myResourceGroup' --name 'myVNetFlowLog' --vnet myVNet --storage-account 'myStorageAccount'
197
+ az network watcher flow-log create --location 'eastus' --resource-group 'myResourceGroup' --name 'myVNetFlowLog' --vnet ' myVNet' --storage-account 'myStorageAccount'
196
198
```
197
199
198
200
``` azurecli-interactive
199
201
# Create a VNet flow log (storage account is in a different resource group from the virtual network).
200
- az network watcher flow-log create --location 'eastus' --resource-group 'myResourceGroup' --name 'myVNetFlowLog' --vnet myVNet --storage-account '/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/StorageRG/providers/Microsoft.Storage/storageAccounts/myStorageAccount'
202
+ az network watcher flow-log create --location 'eastus' --resource-group 'myResourceGroup' --name 'myVNetFlowLog' --vnet ' myVNet' --storage-account '/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/StorageRG/providers/Microsoft.Storage/storageAccounts/myStorageAccount'
201
203
```
202
204
203
205
### Enable virtual network flow logs and traffic analytics
@@ -267,7 +269,7 @@ To enable traffic analytics on a flow log resource, use [Set-AzNetworkWatcherFlo
267
269
$vnet = Get-AzVirtualNetwork -Name 'myVNet' -ResourceGroupName 'myResourceGroup'
268
270
269
271
# Place the storage account configuration into a variable.
270
- $storageAccount = Get-AzStorageAccount -Name 'mynwstorageaccount ' -ResourceGroupName 'Storage '
272
+ $storageAccount = Get-AzStorageAccount -Name 'myStorageAccount ' -ResourceGroupName 'myResourceGroup '
271
273
272
274
# Place the workspace configuration into a variable.
273
275
$workspace = Get-AzOperationalInsightsWorkspace -Name 'myWorkspace' -ResourceGroupName 'myResourceGroup'
@@ -279,13 +281,13 @@ To disable traffic analytics on the flow log resource and continue to generate a
279
281
280
282
```azurepowershell-interactive
281
283
# Place the virtual network configuration into a variable.
282
- $vnet = Get-AzVirtualNetwork -Name myVNet -ResourceGroupName myResourceGroup
284
+ $vnet = Get-AzVirtualNetwork -Name ' myVNet' -ResourceGroupName ' myResourceGroup'
283
285
284
286
# Place the storage account configuration into a variable.
285
- $storageAccount = Get-AzStorageAccount -Name mynwstorageaccount -ResourceGroupName Storage
287
+ $storageAccount = Get-AzStorageAccount -Name 'myStorageAccount' -ResourceGroupName 'myResourceGroup'
286
288
287
289
# Update the VNet flow log.
288
- Set-AzNetworkWatcherFlowLog -Enabled $true -Name myVNetFlowLog -NetworkWatcherName NetworkWatcher_eastus -ResourceGroupName NetworkWatcherRG -StorageId $storageAccount.Id -TargetResourceId $vnet.Id -FormatVersion 2
290
+ Set-AzNetworkWatcherFlowLog -Enabled $true -Name ' myVNetFlowLog' -NetworkWatcherName ' NetworkWatcher_eastus' -ResourceGroupName ' NetworkWatcherRG' -StorageId $storageAccount.Id -TargetResourceId $vnet.Id -FormatVersion 2
289
291
```
290
292
291
293
# [ ** Azure CLI** ] ( #tab/cli )
@@ -455,13 +457,13 @@ Use [Set-AzNetworkWatcherFlowLog](/powershell/module/az.network/set-aznetworkwat
455
457
456
458
```azurepowershell-interactive
457
459
# Place the virtual network configuration into a variable.
458
- $vnet = Get-AzVirtualNetwork -Name myVNet -ResourceGroupName myResourceGroup
460
+ $vnet = Get-AzVirtualNetwork -Name ' myVNet' -ResourceGroupName ' myResourceGroup'
459
461
460
462
# Place the storage account configuration into a variable.
461
- $storageAccount = Get-AzStorageAccount -Name mynwstorageaccount -ResourceGroupName Storage
463
+ $storageAccount = Get-AzStorageAccount -Name 'myStorageAccount' -ResourceGroupName 'myResourceGroup'
462
464
463
465
# Disable the VNet flow log.
464
- Set-AzNetworkWatcherFlowLog -Enabled $false -Name myVNetFlowLog -NetworkWatcherName NetworkWatcher_eastus -ResourceGroupName NetworkWatcherRG -StorageId $storageAccount.Id -TargetResourceId $vnet.Id
466
+ Set-AzNetworkWatcherFlowLog -Enabled $false -Name ' myVNetFlowLog' -NetworkWatcherName ' NetworkWatcher_eastus' -ResourceGroupName ' NetworkWatcherRG' -StorageId $storageAccount.Id -TargetResourceId $vnet.Id
465
467
```
466
468
467
469
> [ !NOTE]
@@ -473,7 +475,7 @@ Use [az network watcher flow-log update](/cli/azure/network/watcher/flow-log#az-
473
475
474
476
``` azurecli-interactive
475
477
# Update the VNet flow log.
476
- az network watcher flow-log update --enabled ' false' --location 'eastus' --name 'myVNetFlowLog' --resource-group 'myResourceGroup' --vnet 'myVNet' --storage-account 'myStorageAccount'
478
+ az network watcher flow-log update --enabled false --location 'eastus' --name 'myVNetFlowLog' --resource-group 'myResourceGroup' --vnet 'myVNet' --storage-account 'myStorageAccount'
477
479
```
478
480
479
481
> [ !NOTE]
@@ -522,5 +524,6 @@ az network watcher flow-log delete --name 'myVNetFlowLog' --location 'eastus'
522
524
523
525
## Related content
524
526
525
- - To learn about traffic analytics, see [ Traffic analytics] ( traffic-analytics.md ) .
526
- - To learn how to use Azure built-in policies to audit or enable traffic analytics, see [ Manage traffic analytics using Azure Policy] ( traffic-analytics-policy-portal.md ) .
527
+ - [ Audit and deploy virtual network flow logs using Azure Policy] ( vnet-flow-logs-policy.md )
528
+ - [ Virtual network flow logs] ( vnet-flow-logs-overview.md )
529
+ - [ Traffic analytics] ( traffic-analytics.md )
0 commit comments