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/network-watcher-alert-triggered-packet-capture.md
+33-31Lines changed: 33 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,13 +9,13 @@ ms.date: 02/14/2024
9
9
ms.custom: devx-track-azurepowershell
10
10
---
11
11
12
-
# Monitor networks proactively with alerts and Azure Functions by using Packet Capture
12
+
# Monitor networks proactively with alerts and Azure Functions by using packet capture
13
13
14
-
Network Watcher packet capture creates capture sessions to track traffic in and out of virtual machines (VMs). The capture file can have a filter that you define to track only the traffic that you want to monitor. This data is stored in a storage blob or locally on the guest machine.
14
+
Azure Network Watcher packet capture creates capture sessions to track traffic in and out of virtual machines (VMs). The capture file can have a filter that you define to track only the traffic that you want to monitor. This data is stored in a storage blob or locally on the guest machine.
15
15
16
-
You can start this capability remotely from other automation scenarios, such as Azure Functions. You can run proactive captures based on defined network anomalies. Other uses include gathering network statistics, getting information about network intrusions, and debugging client/server communications.
16
+
You can start this capability remotely from other automation scenarios, such as from Azure Functions. You can run proactive captures based on defined network anomalies. Other uses include gathering network statistics, getting information about network intrusions, and debugging client/server communications.
17
17
18
-
Resources that are deployed in Azure run continuously. It's difficult to actively monitor the status of all resources at all times. For example, what happens if an issue occurs at 2 AM?
18
+
Resources that are deployed in Azure run continuously. It's difficult to actively monitor the status of all resources at all times. For example, what happens if an problem occurs at 2:00 AM?
19
19
20
20
By using Network Watcher alerts and functions from within the Azure ecosystem, you can proactively respond with the data and tools to solve problems in your network.
21
21
@@ -29,14 +29,15 @@ By using Network Watcher alerts and functions from within the Azure ecosystem, y
29
29
30
30
## Scenario
31
31
32
-
In this example, a virtual machine has more outgoing traffic than usual and you want to be alerted. Similarly, you can create alerts for any condition.
32
+
In this example, a virtual machine has more outgoing traffic than usual and you want to be alerted. You can use a similar process to create alerts for any condition.
33
33
34
-
When an alert is triggered, the packet-level data helps to analyze why the outgoing traffic increased. You can take steps to return the virtual machine to its original state.
34
+
When an incident triggers an alert, the packet-level data helps you analyze why the outgoing traffic increased. You can take steps to return the virtual machine to its original state.
35
35
36
36
This scenario assumes that you have an existing instance of Network Watcher and a resource group with a valid virtual machine.
37
37
38
-
The following workflow takes place when an alert is triggered on your VM:
38
+
Here's the workflow for packet capture:
39
39
40
+
1. An incident triggers an alert on your VM.
40
41
1. The alert calls your Azure function.
41
42
1. Your Azure function processes the alert and starts a Network Watcher packet capture session.
42
43
1. The packet capture runs on the VM and collects data.
@@ -55,24 +56,24 @@ To create an Azure function to process the alert and create a packet capture, fo
55
56
56
57
1. Sign in to the [Azure portal](https://portal.azure.com).
57
58
58
-
1. In the search box at the top of the portal, enter *function app*. Select **Function App** from the search results
59
+
1. In the search box at the top of the portal, enter *function app*. Select **Function App** from the search results.
59
60
60
61
:::image type="content" source="./media/network-watcher-alert-triggered-packet-capture/function-app-portal-search.png" alt-text="Screenshot that shows how to search for function apps in the Azure portal." lightbox="./media/network-watcher-alert-triggered-packet-capture/function-app-portal-search.png":::
61
62
62
63
1. Select **+ Create**.
63
64
64
65
1. On the **Basics** tab of **Create Function App**, enter or select values for the following settings:
65
66
66
-
- Under **Project Details**, select the subscription for which you want to create the function app and the resource group value to contain the app.
67
+
- Under **Project Details**, select the subscription for which you want to create the function app and the resource group to contain the app.
67
68
- Under **Instance Details**:
68
69
- For **Function app name**, enter the name of the function app. This name is appended by *.azurewebsites.net*.
69
-
- For **Do you want to deploy code or container image?**, select the mode of publishing: either **Code** or **Container image**.
70
+
- For **Do you want to deploy code or container image?**, select the mode of publishing: **Code** or **Container image**.
70
71
- For **Runtime stack**, select a runtime stack.
71
72
- For **Version**, select the version of the runtime stack.
72
73
- For **Region**, select the region in which you want to create the function app.
73
-
- Under **Operating system**, select the type of operating system that you're currently using. Azure recommends the type of operating system based on your runtime stack selection.
74
+
- Under **Operating system**, select the type of operating system that you currently use. Azure recommends the type of operating system based on your runtime stack selection.
74
75
- Under **Hosting**, select the type of plan that you want to use for the function app. Choose from the following options:
75
-
-**Consumption (Serverless)**: For event-driven scaling for the most minimum cost.
76
+
-**Consumption (Serverless)**: For event-driven scaling for the lowest cost.
76
77
-**Functions Premium**: For enterprise-level, serverless applications with event-based scaling and network isolation.
77
78
-**App Service plan**: For reusing compute from an existing Azure App Service plan.
78
79
@@ -90,11 +91,11 @@ To create an Azure function to process the alert and create a packet capture, fo
90
91
3. Under **Select a template**, select **HTTP trigger**.
91
92
4. In the **Template details** section:
92
93
- For **New Function**, enter the name of the function.
93
-
- For **Authorization level**, select **Function**
94
+
- For **Authorization level**, select **Function**.
94
95
5. Select **Create**.
95
-
6.After the function is created, go to the function and select **Code + Test**.
96
+
6.Go to the function that you created and select **Code + Test**.
96
97
97
-
:::image type="content" source="./media/network-watcher-alert-triggered-packet-capture/code-test.png" alt-text="Screenshot of the Code + Test screen.":::
98
+
:::image type="content" source="./media/network-watcher-alert-triggered-packet-capture/code-test.png" alt-text="Screenshot of the Code + Test page for a function.":::
98
99
99
100
7. Update the [script](#add-powershell-to-the-function) and select **Save**.
100
101
@@ -164,7 +165,7 @@ Get the tenant ID by running the following PowerShell cmdlet:
164
165
165
166
#### AzureCredPassword
166
167
167
-
The value of the `AzureCredPassword` environment variable is the value that you get from running the following PowerShell sample. This example is the same one that's shown in the preceding [Authentication](#authentication) section. The value that you need is the output of the `$Encryptedpassword` variable. This is the service principal password that you encrypted by using the PowerShell script.
168
+
The value of the `AzureCredPassword` environment variable is the value that you get from running the following PowerShell sample. This example is the same one thatthe preceding [Authentication](#authentication) section showed. The value that you need is the output of the `$Encryptedpassword` variable. This is the service principal password that you encrypted by using the PowerShell script.
168
169
169
170
```powershell
170
171
#Variables
@@ -315,15 +316,15 @@ if ($requestBody.context.resourceType -eq "Microsoft.Compute/virtualMachines") {
315
316
316
317
## Configure an alert on a VM
317
318
318
-
You can configure alerts to notify individuals when a specific metric crosses a threshold that's assigned to it. In this example, the alert is on the Network Out Total that is sent, but the alert can be triggered for many other metrics.
319
+
You can configure alerts to notify individuals when a specific metric crosses a threshold that you assigned to it. In this example, the alert is on the Network Out Total metric that's sent, but you can trigger the alert for many other metrics.
319
320
320
321
### Create the alert rule
321
322
322
-
Go to an existing virtual machine and [add an alert rule](../azure-monitor/alerts/alerts-classic-portal.md). Do the following in the **Create an Alert rule**screen.
323
+
Go to an existing virtual machine and [add an alert rule](../azure-monitor/alerts/alerts-classic-portal.md). On the **Create an Alert rule**page, take the following steps:
323
324
324
-
1.In the **Select a signal** pane, search for the name of the signal and select it. In this example, Network Out Total is the selected signal. It denotes the number of bytes out on all network interfaces by the Virtual Machine.
325
+
1.On the **Select a signal** pane, search for the name of the signal and select it. In this example, **Network Out Total** is the selected signal. It denotes the number of bytes out on all network interfaces by the virtual machine.
325
326
326
-
2.In the **Conditions** tab, set the following values and select **Next: Actions >**.
327
+
2.On the **Conditions** tab, set the following values, and then select **Next: Actions**.
327
328
328
329
|**Setting**|**Value**|
329
330
|---|---|
@@ -334,23 +335,24 @@ Go to an existing virtual machine and [add an alert rule](../azure-monitor/alert
334
335
|**Check every**|1 minute|
335
336
|**Lookback period**|5 minutes|
336
337
337
-
3. In the **Actions** tab, select **Create an action group**.
338
-
4. In the **Create action group** screen, select the **Subscription**, **Resource group**, and **Region**. Also enter the Action group name and the display name and select **Next: Notifications >**.
339
-
5. In the screen that appears, select **Action type** as **Azure Function**.
340
-
6. In the Azure Function pane, select the **Subscription**, **Resource group**, **Function app**, and **Azure Function**.
341
-
:::image type="content" source="./media/network-watcher-alert-triggered-packet-capture/action-group.png" alt-text="Screenshot of the Create action group screen.":::
342
-
7. Select **No** in **Enable the common alert schema** slider and select **OK**.
338
+
3. On the **Actions** tab, select **Create an action group**.
339
+
4. On the **Create action group** page, select the **Subscription**, **Resource group**, and **Region** values. Also enter the action group name and the display name, and then select **Next: Notifications**.
340
+
5. On the **Notifications** tab, for **Action type**, select **Azure Function**.
341
+
6. On the **Azure Function** pane, select the **Subscription**, **Resource group**, **Function app**, and **Azure Function** values.
342
+
343
+
:::image type="content" source="./media/network-watcher-alert-triggered-packet-capture/action-group.png" alt-text="Screenshot of the page for creating an action group and the pane for details about an Azure function.":::
344
+
7. In **Enable the common alert schema** slider, select **No**. Then select **OK**.
343
345
344
346
## Review the results
345
347
346
-
After the criteria for the alert triggers, a packet capture is created. Go to Network Watcher and select **Packet capture**. On this page, you can select the packet capture file link to download the packet capture.
348
+
After the criteria trigger an alert, Network Watcher creates a packet capture. Go to Network Watcher and select **Packet capture**. On this page, you can select the file link to download the packet capture.
347
349
348
-
If the capture file is stored locally, you can retrieve it by signing in to the virtual machine.
350
+
If the capture file is stored locally, you can get it by signing in to the virtual machine.
349
351
350
-
For instructions on downloading files from Azure storage accounts, see [Get started with Azure Blob storage using .NET](../storage/blobs/storage-quickstart-blobs-dotnet.md). You can also use the [Storage Explorer](https://storageexplorer.com/) tool.
352
+
For instructions on downloading files from Azure storage accounts, see the [quickstart for the Azure Blob Storage client library for .NET](../storage/blobs/storage-quickstart-blobs-dotnet.md). You can also use the [Azure Storage Explorer](https://storageexplorer.com/) tool.
351
353
352
-
After your capture has been downloaded, you can view it using tools like [Microsoft Message Analyzer](/message-analyzer/microsoft-message-analyzer-operating-guide) and [WireShark](https://www.wireshark.org/)that can read a **.cap** file.
354
+
After you download your capture, you can view it by using tools like [Wireshark](https://www.wireshark.org/)that can read a *.cap* file.
353
355
354
356
## Next step
355
357
356
-
Learn how to view your packet captures by visiting [Packet capture analysis with Wireshark](network-watcher-deep-packet-inspection.md).
358
+
Learn how to view your packet captures by reading [Inspect and analyze Network Watcher packet capture files](network-watcher-deep-packet-inspection.md).
0 commit comments