Manage Network Watcher Agent virtual machine extension for Linux

The Network Watcher Agent virtual machine extension is a requirement for some of Azure Network Watcher features that capture network traffic to diagnose and monitor Azure virtual machines (VMs). For more information, see What is Azure Network Watcher?

In this article, you learn how to install and uninstall Network Watcher Agent for Linux. Installation of the agent doesn't disrupt, or require a reboot of the virtual machine. If the virtual machine is deployed by an Azure service, check the documentation of the service to determine whether or not it permits installing extensions in the virtual machine.

Note

Network Watcher Agent extension is not supported on AKS clusters.

Prerequisites

  • An Azure Linux virtual machine (VM). For more information, see Supported Linux distributions and versions.

  • Outbound TCP connectivity to 169.254.169.254 over port 80 and 168.63.129.16 over port 8037. The agent uses these IP addresses to communicate with the Azure platform.

  • Internet connectivity: Network Watcher Agent requires internet connectivity for some features to properly work. For example, it requires connectivity to your storage account to upload packet captures. For more information, see Packet capture overview.

  • Azure PowerShell.

    You can install Azure PowerShell locally to run the cmdlets. If you run PowerShell locally, sign in to Azure using the Connect-AzAccount -Environment AzureChinaCloud cmdlet.

Supported operating systems

Network Watcher Agent extension for Linux can be installed on the following Linux distributions:

Distribution Version
AlmaLinux 9.2
Azure Linux 2.0
CentOS 1 6.10 and 7
Debian 7 and 8
OpenSUSE Leap 42.3+
SUSE Linux Enterprise Server (SLES) 12 and 15 (SP2, SP3, and SP4)
Ubuntu 16+

1 CentOS Linux reached its end-of-life (EOL) on June 30, 2024. For more information, see the CentOS End Of Life guidance.

Extension schema

The following JSON shows the schema for the Network Watcher Agent extension. The extension doesn't require, or support, any user-supplied settings. The extension relies on its default configuration.

{
    "name": "[concat(parameters('vmName'), '/AzureNetworkWatcherExtension')]",
    "type": "Microsoft.Compute/virtualMachines/extensions",
    "apiVersion": "2023-03-01",
    "location": "[resourceGroup().location]",
    "dependsOn": [
        "[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'))]"
    ],
    "properties": {
        "autoUpgradeMinorVersion": true,
        "publisher": "Microsoft.Azure.NetworkWatcher",
        "type": "NetworkWatcherAgentLinux",
        "typeHandlerVersion": "1.4"
    }
}

List installed extensions

Use Get-AzVMExtension cmdlet to list all installed extensions on the virtual machine:

# List the installed extensions on the virtual machine.
Get-AzVMExtension -ResourceGroupName 'myResourceGroup' -VMName 'myVM' | format-table Name, Publisher, ExtensionType, AutoUpgradeMinorVersion, EnableAutomaticUpgrade

The output of the cmdlet lists the installed extensions:

Name                         Publisher                      ExtensionType            AutoUpgradeMinorVersion EnableAutomaticUpgrade
----                         ---------                      -------------            ----------------------- ----------------------
AzureNetworkWatcherExtension Microsoft.Azure.NetworkWatcher NetworkWatcherAgentLinux                    True                   True

Install Network Watcher Agent VM extension

Use Set-AzVMExtension cmdlet to install Network Watcher Agent VM extension on the virtual machine:

# Install Network Watcher Agent for Linux on the virtual machine.
Set-AzVMExtension -Name 'AzureNetworkWatcherExtension' -Publisher 'Microsoft.Azure.NetworkWatcher' -ExtensionType 'NetworkWatcherAgentLinux' -EnableAutomaticUpgrade 1 -TypeHandlerVersion '1.4' -ResourceGroupName 'myResourceGroup' -VMName 'myVM' 

Once the installation is successfully completed, you see the following output:

RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
                         True         OK 

Uninstall Network Watcher Agent VM extension

Use Remove-AzVMExtension cmdlet to remove Network Watcher Agent VM extension from the virtual machine:

# Uninstall Network Watcher Agent VM extension.
Remove-AzureVMExtension -Name 'AzureNetworkWatcherExtension' -ResourceGroupName 'myResourceGroup' -VMName 'myVM'

Frequently asked questions (FAQ)

To get answers to most frequently asked questions about Network Watcher Agent, see Network Watcher Agent FAQ.