You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/network-watcher/nsg-flow-logs-manage.md
+125-3Lines changed: 125 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,19 +71,19 @@ In this article, you learn how to create, change, enable, disable, or delete a n
71
71
72
72
*Microsoft.Insights* provider must be registered to successfully log traffic flowing through a virtual network. If you aren't sure if the *Microsoft.Insights* provider is registered, check its status in the Azure portal by following these steps:
73
73
74
-
1. In the search box at the top of the portal, enter *subscriptions*. Select **Subscriptions** from the search results.
74
+
1. In the search box at the top of the portal, enter ***subscriptions***. Select **Subscriptions** from the search results.
75
75
76
76
:::image type="content" source="./media/subscriptions-portal-search.png" alt-text="Screenshot that shows how to search for Subscriptions in the Azure portal." lightbox="./media/subscriptions-portal-search.png":::
77
77
78
78
1. Select the Azure subscription that you want to enable the provider for in **Subscriptions**.
79
79
80
80
1. Under **Settings**, select **Resource providers**.
81
81
82
-
1. Enter *insight* in the filter box.
82
+
1. Enter ***insight*** in the filter box.
83
83
84
84
1. Confirm the status of the provider displayed is **Registered**. If the status is **NotRegistered**, select the **Microsoft.Insights** provider then select **Register**.
85
85
86
-
:::image type="content" source="./media/nsg-flow-logs-portal/register-microsoft-insights.png" alt-text="Screenshot that shows how to register Microsoft Insights provider in the Azure portal." lightbox="./media/nsg-flow-logs-portal/register-microsoft-insights.png":::
86
+
:::image type="content" source="./media/register-microsoft-insights.png" alt-text="Screenshot that shows how to register Microsoft Insights provider in the Azure portal." lightbox="./media/register-microsoft-insights.png":::
87
87
88
88
# [**PowerShell**](#tab/powershell)
89
89
@@ -105,6 +105,128 @@ az provider register --namespace 'Microsoft.Insights'
105
105
106
106
---
107
107
108
+
## Create a flow log
109
+
110
+
Create a flow log for your network security group. The flow log is saved in an Azure storage account.
111
+
112
+
# [**Portal**](#tab/portal)
113
+
114
+
1. In the search box at the top of the portal, enter ***network watcher***. Select **Network Watcher** from the search results.
115
+
116
+
1. Under **Logs**, select **Flow logs**.
117
+
118
+
1. In **Network Watcher | Flow logs**, select **+ Create** or **Create flow log** blue button.
119
+
120
+
:::image type="content" source="./media/nsg-flow-logs-portal/flow-logs.png" alt-text="Screenshot of Flow logs page in the Azure portal." lightbox="./media/nsg-flow-logs-portal/flow-logs.png":::
121
+
122
+
1. On the **Basics** tab of **Create a flow log**, enter or select the following values:
123
+
124
+
| Setting | Value |
125
+
| ------- | ----- |
126
+
|**Project details**||
127
+
| Subscription | Select the Azure subscription of your network security group that you want to log. |
128
+
| Flow log type | Select **Network security group** then select **+ Select target resource**. <br> Select the network security group that you want to flow log, then select **Confirm selection**. |
129
+
| Flow Log Name | Enter a name for the flow log or leave the default name. Azure portal uses ***{ResourceName}-{ResourceGroupName}-flowlog*** as a default name for the flow log. **myNSG-myResourceGroup-flowlog** is the default name used in this article. |
130
+
|**Instance details**||
131
+
| Subscription | Select the Azure subscription of your storage account. |
132
+
| Storage accounts | Select the storage account that you want to save the flow logs to. If you want to create a new storage account, select **Create a new storage account**. |
133
+
| Retention (days) | Enter a retention time for the logs (this option is only available with [Standard general-purpose v2](../storage/common/storage-account-overview.md?toc=/azure/network-watcher/toc.json#types-of-storage-accounts) storage accounts). Enter *0* if you want to retain the flow logs data in the storage account forever (until you delete it from the storage account). For information about pricing, see [Azure Storage pricing](https://azure.microsoft.com/pricing/details/storage/). |
134
+
135
+
:::image type="content" source="./media/nsg-flow-logs-portal/create-nsg-flow-log-basics.png" alt-text="Screenshot of creating an NSG flow log in the Azure portal.":::
136
+
137
+
> [!NOTE]
138
+
> If the storage account is in a different subscription, the network security group and storage account must be associated with the same Microsoft Entra tenant. The account you use for each subscription must have the [necessary permissions](required-rbac-permissions.md).
139
+
140
+
1. To enable traffic analytics, select **Next: Analytics** button, or select the **Analytics** tab. Enter or select the following values:
141
+
142
+
| Setting | Value |
143
+
| ------- | ----- |
144
+
| Flow logs version | Select the version of the network security group flow log, available options are: **Version 1** and **Version 2**. The default version is version 2. For more information, see [Flow logging for network security groups](nsg-flow-logs-overview.md). |
145
+
| Enable traffic analytics | Select the checkbox to enable traffic analytics for your flow log. |
146
+
| Traffic analytics processing interval | Select the processing interval that you prefer, available options are: **Every 1 hour** and **Every 10 mins**. The default processing interval is every one hour. For more information, see [Traffic analytics](traffic-analytics.md). |
147
+
| Subscription | Select the Azure subscription of your Log Analytics workspace. |
148
+
| Log Analytics Workspace | Select your Log Analytics workspace. By default, Azure portal creates ***DefaultWorkspace-{SubscriptionID}-{Region}*** Log Analytics workspace in ***defaultresourcegroup-{Region}*** resource group. |
149
+
150
+
:::image type="content" source="./media/nsg-flow-logs-portal/create-nsg-flow-log-analytics.png" alt-text="Screenshot that shows how to enable traffic analytics for a new flow log in the Azure portal.":::
151
+
152
+
> [!NOTE]
153
+
> To create and select a Log Analytics workspace other than the default one, see [Create a Log Analytics workspace](/azure/azure-monitor/logs/quick-create-workspace?toc=/azure/network-watcher/toc.json)
154
+
155
+
1. Select **Review + create**.
156
+
157
+
1. Review the settings, and then select **Create**.
158
+
159
+
160
+
# [**PowerShell**](#tab/powershell)
161
+
162
+
1. Get the properties of the network security group that you want to create the flow log for and the storage account that you want to use to store the created flow log using [Get-AzNetworkSecurityGroup](/powershell/module/az.network/get-aznetworksecuritygroup) and [Get-AzStorageAccount](/powershell/module/az.storage/get-azstorageaccount) respectively.
163
+
164
+
```azurepowershell-interactive
165
+
# Place the network security group properties into a variable.
> - If the storage account is in a different subscription, the network security group and storage account must be associated with the same Azure Active Directory tenant. The account you use for each subscription must have the [necessary permissions](required-rbac-permissions.md).
174
+
175
+
1. Create the flow log using [New-AzNetworkWatcherFlowLog](/powershell/module/az.network/new-aznetworkwatcherflowlog). The flow log is created in the Network Watcher default resource group **NetworkWatcherRG**.
Create a flow log using [az network watcher flow-log create](/cli/azure/network/watcher/flow-log#az-network-watcher-flow-log-create). The flow log is created in the Network Watcher default resource group **NetworkWatcherRG**.
> If the storage account is in a different subscription, the network security group and storage account must be associated with the same Azure Active Directory tenant. The account you use for each subscription must have the [necessary permissions](required-rbac-permissions.md).
199
+
200
+
## Create a flow log and traffic analytics workspace
201
+
202
+
1. Create a Log Analytics workspace using [az monitor log-analytics workspace create](/cli/azure/monitor/log-analytics/workspace#az-monitor-log-analytics-workspace-create).
203
+
204
+
```azurecli-interactive
205
+
# Create a Log Analytics workspace.
206
+
az monitor log-analytics workspace create --name 'myWorkspace' --resource-group 'myResourceGroup'
207
+
```
208
+
209
+
1. Create a flow log using [az network watcher flow-log create](/cli/azure/network/watcher/flow-log#az-network-watcher-flow-log-create). The flow log is created in the Network Watcher default resource group **NetworkWatcherRG**.
210
+
211
+
```azurecli-interactive
212
+
# Create a version 1 NSG flow log and enable traffic analytics for it.
# Create a version 1 NSG flow log and enable traffic analytics for it (storage account and traffic analytics workspace are in different resource groups from the network security group).
> - The storage account can't have network rules that restrict network access to only Microsoft services or specific virtual networks.
223
+
> - If the storage account is in a different subscription, the network security group and storage account must be associated with the same Azure Active Directory tenant. The account you use for each subscription must have the [necessary permissions](required-rbac-permissions.md).
224
+
225
+
226
+
---
227
+
228
+
229
+
108
230
## Related content
109
231
110
232
- [Audit and deploy NSG flow logs using Azure Policy](nsg-flow-logs-policy-portal.md)
0 commit comments