Skip to content

Commit 0b41d13

Browse files
Merge pull request #246098 from halkazwini/nw-tut-nsg
Network Watcher: Updates: Tutorial: Log network traffic to and from a virtual machine using the Azure portal
2 parents 993e7af + ee42a50 commit 0b41d13

File tree

1 file changed

+41
-51
lines changed

1 file changed

+41
-51
lines changed

articles/network-watcher/network-watcher-nsg-flow-logging-portal.md

Lines changed: 41 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to log network traffic flow to and from a virtual machine
55
author: halkazwini
66
ms.service: network-watcher
77
ms.topic: tutorial
8-
ms.date: 05/31/2023
8+
ms.date: 07/24/2023
99
ms.author: halkazwini
1010
ms.custom: template-tutorial, mvc, engagement-fy23
1111
# Customer intent: I need to log the network traffic to and from a virtual machine (VM) so I can analyze it for anomalies.
@@ -20,10 +20,10 @@ This tutorial helps you use NSG flow logs to log a virtual machine's network tra
2020
In this tutorial, you learn how to:
2121

2222
> [!div class="checklist"]
23-
> * Create a virtual network and a Bastion host
23+
> * Create a virtual network
2424
> * Create a virtual machine with a network security group associated to its network interface
2525
> * Register Microsoft.insights provider
26-
> * Enable flow logging for a network security group using Network Watcher NSG flow logs
26+
> * Enable flow logging for a network security group using Network Watcher flow logs
2727
> * Download logged data
2828
> * View logged data
2929
@@ -35,11 +35,11 @@ In this tutorial, you learn how to:
3535

3636
Sign in to the [Azure portal](https://portal.azure.com).
3737

38-
## Create a virtual network and a Bastion host
38+
## Create a virtual network
3939

40-
In this section, you create **myVNet** virtual network with two subnets and an Azure Bastion host. The first subnet is used for the virtual machine, and the second subnet is used for the Bastion host.
40+
In this section, you create **myVNet** virtual network with one subnet for the virtual machine.
4141

42-
1. In the search box at the top of the portal, enter *virtual networks*. Select **Virtual networks** in the search results.
42+
1. In the search box at the top of the portal, enter *virtual networks*. Select **Virtual networks** from the search results.
4343

4444
:::image type="content" source="./media/network-watcher-nsg-flow-logging-portal/virtual-network-azure-portal.png" alt-text="Screenshot shows searching for virtual networks in the Azure portal.":::
4545

@@ -52,25 +52,7 @@ In this section, you create **myVNet** virtual network with two subnets and an A
5252
| Resource Group | Select **Create new**. </br> Enter *myResourceGroup* in **Name**. </br> Select **OK**. |
5353
| **Instance details** | |
5454
| Name | Enter *myVNet*. |
55-
| Region | Select **East US**. |
56-
57-
1. Select the **Security** tab, or select the **Next** button at the bottom of the page.
58-
59-
1. Under **Azure Bastion**, select **Enable Azure Bastion** and accept the default values:
60-
61-
| Setting | Value |
62-
| --- | --- |
63-
| Azure Bastion host name | **myVNet-Bastion**. |
64-
| Azure Bastion public IP Address | **(New) myVNet-bastion-publicIpAddress**. |
65-
66-
1. Select the **IP Addresses** tab, or select **Next** button at the bottom of the page.
67-
68-
1. Accept the default IP address space **10.0.0.0/16** and rename the **default** subnet by selecting the pencil icon next to it. In the **Edit subnet** page, enter the subnet name:
69-
70-
| Setting | Value |
71-
| --- | --- |
72-
| **Subnet details** | |
73-
| Name | Enter *mySubnet*. |
55+
| Region | Select **(US) East US**. |
7456

7557
1. Select **Review + create**.
7658

@@ -80,11 +62,11 @@ In this section, you create **myVNet** virtual network with two subnets and an A
8062

8163
In this section, you create **myVM** virtual machine.
8264

83-
1. In the search box at the top of the portal, enter *virtual machines*. Select **Virtual machines** in the search results.
65+
1. In the search box at the top of the portal, enter *virtual machines*. Select **Virtual machines** from the search results.
8466

85-
2. Select **+ Create** and then select **Azure virtual machine**.
67+
1. Select **+ Create** and then select **Azure virtual machine**.
8668

87-
3. In **Create a virtual machine**, enter or select the following values in the **Basics** tab:
69+
1. In **Create a virtual machine**, enter or select the following values in the **Basics** tab:
8870

8971
| Setting | Value |
9072
| --- | --- |
@@ -103,30 +85,34 @@ In this section, you create **myVM** virtual machine.
10385
| Password | Enter a password. |
10486
| Confirm password | Reenter password. |
10587

106-
4. Select the **Networking** tab, or select **Next: Disks**, then **Next: Networking**.
88+
1. Select the **Networking** tab, or select **Next: Disks**, then **Next: Networking**.
10789

108-
5. In the Networking tab, select the following values:
90+
1. In the Networking tab, select the following values:
10991

11092
| Setting | Value |
11193
| --- | --- |
11294
| **Network interface** | |
11395
| Virtual network | Select **myVNet**. |
11496
| Subnet | Select **mySubnet**. |
115-
| Public IP | Select **None**. |
97+
| Public IP | Select **(new) myVM-ip**. |
11698
| NIC network security group | Select **Basic**. This setting creates a network security group named **myVM-nsg** and associates it with the network interface of **myVM** virtual machine. |
117-
| Public inbound ports | Select **None**. |
99+
| Public inbound ports | Select **Allow selected ports**. |
100+
| Select inbound ports | Select **RDP (3389)**. |
118101

119-
6. Select **Review + create**.
102+
> [!CAUTION]
103+
> Leaving the RDP port open to the internet is only recommended for testing. For production environments, it's recommended to restrict access to the RDP port to a specific IP address or range of IP addresses. You can also block internet access to the RDP port and use [Azure Bastion](../bastion/bastion-overview.md) to securely connect to your virtual machine from the Azure portal.
120104
121-
7. Review the settings, and then select **Create**.
105+
1. Select **Review + create**.
106+
107+
1. Review the settings, and then select **Create**.
122108

123-
8. Once the deployment is complete, select **Go to resource** to go to the **Overview** page of **myVM**.
109+
1. Once the deployment is complete, select **Go to resource** to go to the **Overview** page of **myVM**.
124110

125-
9. Select **Connect** then select **Bastion**.
111+
1. Select **Connect** then select **RDP**.
126112

127-
10. Enter the username and password that you created in the previous steps. Leave **Open in new browser tab** checked.
113+
1. Select **Download RDP File** and open the downloaded file.
128114

129-
11. Select **Connect** button.
115+
1. Select **Connect** and then enter the username and password that you created in the previous steps. Accept the certificate if prompted.
130116

131117
## Register Insights provider
132118

@@ -161,7 +147,7 @@ In this section, you create a storage account to use it to store the flow logs.
161147
| Storage account name | Enter a unique name. This tutorial uses **mynwstorageaccount**. |
162148
| Region | Select **(US) East US**. The storage account must be in the same region as the virtual machine and its network security group. |
163149
| Performance | Select **Standard**. NSG flow logs only support Standard-tier storage accounts. |
164-
| Redundancy | Select **Locally-redundant storage (LRS)**. |
150+
| Redundancy | Select **Locally-redundant storage (LRS)** or different replication strategy that matches your durability requirements. |
165151

166152
1. Select the **Review** tab or select the **Review** button at the bottom.
167153

@@ -205,9 +191,9 @@ In this section, you create an NSG flow log that's saved into the storage accoun
205191

206192
:::image type="content" source="./media/network-watcher-nsg-flow-logging-portal/flow-logs-list.png" alt-text="Screenshot of Flow logs page in the Azure portal showing the newly created flow log." lightbox="./media/network-watcher-nsg-flow-logging-portal/flow-logs-list.png":::
207193

208-
1. Go back to your browser tab of **myVM** virtual machine.
194+
1. Go back to your RDP session with **myVM** virtual machine.
209195

210-
1. In **myVM**, open Microsoft Edge and go to `www.bing.com`.
196+
1. Open Microsoft Edge and go to `www.bing.com`.
211197

212198
## Download the flow log
213199

@@ -223,7 +209,9 @@ In this section, you go to the storage account you previously selected and downl
223209

224210
5. In the container, navigate the folder hierarchy until you get to the `PT1H.json` file. NSG log files are written to a folder hierarchy that follows the following naming convention:
225211

226-
**https://{storageAccountName}.blob.core.windows.net/insights-logs-networksecuritygroupflowevent/resourceId=/SUBSCRIPTIONS/{subscriptionID}/RESOURCEGROUPS/{resourceGroupName}/PROVIDERS/MICROSOFT.NETWORK/NETWORKSECURITYGROUPS/{networSecurityGroupName}/y={year}/m={month}/d={day}/h={hour}/m=00/macAddress={macAddress}/PT1H.json**
212+
```
213+
https://{storageAccountName}.blob.core.windows.net/insights-logs-networksecuritygroupflowevent/resourceId=/SUBSCRIPTIONS/{subscriptionID}/RESOURCEGROUPS/{resourceGroupName}/PROVIDERS/MICROSOFT.NETWORK/NETWORKSECURITYGROUPS/{networSecurityGroupName}/y={year}/m={month}/d={day}/h={hour}/m=00/macAddress={acAddress}/PT1H.json
214+
```
227215
228216
6. Select the ellipsis **...** to the right of the PT1H.json file, then select **Download**.
229217
@@ -285,23 +273,25 @@ The comma-separated information for **flowTuples** is as follows:
285273

286274
When no longer needed, delete **myResourceGroup** resource group and all of the resources it contains and **myVM-nsg-myResourceGroup-flowlog** flow log:
287275

288-
**Delete the flow log**:
276+
**Delete the resource group**:
289277

290-
1. In the search box at the top of the portal, enter *network watcher*. Select **Network Watcher** in the search results.
278+
1. In the search box at the top of the portal, enter ***myResourceGroup***. Select **myResourceGroup** from the search results.
291279

292-
1. Under **Logs**, select **Flow logs**.
280+
1. Select **Delete resource group**.
293281

294-
1. In **Network Watcher | Flow logs**, select the checkbox of the flow log.
282+
1. In **Delete a resource group**, enter ***myResourceGroup***, and then select **Delete**.
295283

296-
1. Select **Delete**.
284+
1. Select **Delete** to confirm the deletion of the resource group and all its resources.
297285

298-
**Delete the resource group**:
286+
**Delete the flow log**:
299287

300-
1. In the search box at the top of the portal, enter *myResourceGroup*. When you see **myResourceGroup** in the search results, select it.
288+
1. In the search box at the top of the portal, enter ***network watcher***. Select **Network Watcher** from the search results.
301289

302-
1. Select **Delete resource group**.
290+
1. Under **Logs**, select **Flow logs**.
303291

304-
1. Enter *myResourceGroup* for **TYPE THE RESOURCE GROUP NAME:** and select **Delete**.
292+
1. In **Network Watcher | Flow logs**, select the checkbox of the flow log.
293+
294+
1. Select **Delete**.
305295

306296
## Next steps
307297

0 commit comments

Comments
 (0)