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, update, and uninstall Network Watcher Agent for Windows and 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 the service permits installing extensions in the virtual machine.
Note
Network Watcher Agent extension isn't supported on AKS clusters.
Prerequisites
An Azure virtual machine (VM) running a supported operating system. For more information, see Supported operating systems.
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 work properly. For example, it requires connectivity to your storage account to upload packet captures.
An Azure virtual machine (VM) running a supported operating system. For more information, see Supported operating systems.
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 work properly. For example, it requires connectivity to your storage account to upload packet captures.
Azure Cloud Shell or Azure PowerShell.
The steps in this article run the Azure PowerShell cmdlets interactively in Azure Cloud Shell. To run the commands in the Cloud Shell, select Open Cloud Shell at the upper-right corner of a code block. Select Copy to copy the code and then paste it into Cloud Shell to run it. You can also run the Cloud Shell from within the Azure portal.
You can also install Azure PowerShell locally to run the cmdlets. If you run PowerShell locally, sign in to Azure using the Connect-AzAccount cmdlet.
An Azure virtual machine (VM) running a supported operating system. For more information, see Supported operating systems.
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 work properly. For example, it requires connectivity to your storage account to upload packet captures.
Azure Cloud Shell or Azure CLI.
The steps in this article run the Azure CLI commands interactively in Azure Cloud Shell. To run the commands in the Cloud Shell, select Open Cloud Shell at the upper-right corner of a code block. Select Copy to copy the code, and paste it into Cloud Shell to run it. You can also run the Cloud Shell from within the Azure portal.
You can also install Azure CLI locally to run the commands. If you run Azure CLI locally, sign in to Azure using the az login command.
An Azure virtual machine (VM) running a supported operating system. For more information, see Supported operating systems.
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 work properly. For example, it requires connectivity to your storage account to upload packet captures.
Azure PowerShell or Azure CLI installed locally to deploy the template.
Supported operating systems
You can install the Network Watcher Agent extension for Windows on the following operating systems:
- Windows Server 2012, 2012 R2, 2016, 2019, 2022, and 2025 releases.
- Windows 10 and 11 releases.
Note
Currently, Nano Server isn't supported.
You can install the Network Watcher Agent extension for Linux 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+ |
| Oracle Linux |
6.10 2, 7, 8, and 9+ |
| Red Hat Enterprise Linux (RHEL) |
6.10 3, 7, 8, and 9.2 |
| Rocky Linux |
9.1 |
| 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.
2 Extended life cycle (ELS) support for Oracle Linux version 6.X ended on July 1, 2024.
3 Extended life cycle (ELS) support for Red Hat Enterprise Linux 6.X ended on June 30, 2024.
Note
Internet Control Message Protocol (ICMP) monitoring isn't currently supported in the Network Watcher Agent on Oracle Linux due to known kernel-level limitations specific to the distro.
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, and it 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": "NetworkWatcherAgentWindows",
"typeHandlerVersion": "1.4"
}
}
{
"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
From the virtual machine page in the Azure portal, you can view the installed extensions by following these steps:
Under Settings, select Extensions + applications.
In the Extensions tab, you can see all installed extensions on the virtual machine. If the list is long, use the search box to filter the list.
Use the 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 NetworkWatcherAgentWindows True True
Name Publisher ExtensionType AutoUpgradeMinorVersion EnableAutomaticUpgrade
---- --------- ------------- ----------------------- ----------------------
AzureNetworkWatcherExtension Microsoft.Azure.NetworkWatcher NetworkWatcherAgentLinux True True
Use the az vm extension list command to list all installed extensions on the virtual machine.
# List the installed extensions on the virtual machine.
az vm extension list --resource-group 'myResourceGroup' --vm-name 'myVM' --out table
The output of the command lists the installed extensions:
Name ProvisioningState Publisher Version AutoUpgradeMinorVersion
---------------------------- ------------------- ------------------------------ --------- -------------------------
AzureNetworkWatcherExtension Succeeded Microsoft.Azure.NetworkWatcher 1.4 True
Install Network Watcher Agent VM extension
From the virtual machine page in the Azure portal, you can install the Network Watcher Agent VM extension by following these steps:
Under Settings, select Extensions + applications.
Select + Add, search for Network Watcher Agent, and install it. If the extension is already installed, you can see it in the list of extensions.
In the search box of Install an Extension, enter Network Watcher Agent, select the matching extension for your operating system from the list, and then select Next.
Select Review + create and then select Create.
Use the Set-AzVMExtension cmdlet to install the Network Watcher Agent VM extension on the virtual machine:
# Install Network Watcher Agent for Windows on the virtual machine.
Set-AzVMExtension -Name 'AzureNetworkWatcherExtension' -Publisher 'Microsoft.Azure.NetworkWatcher' -ExtensionType 'NetworkWatcherAgentWindows' -EnableAutomaticUpgrade 1 -TypeHandlerVersion '1.4' -ResourceGroupName 'myResourceGroup' -VMName 'myVM'
# 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'
When the installation finishes, you see the following output:
RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK
Use the az vm extension set command to install the Network Watcher Agent VM extension on the virtual machine:
# Install Network Watcher Agent for Windows on the virtual machine.
az vm extension set --name 'NetworkWatcherAgentWindows' --extension-instance-name 'AzureNetworkWatcherExtension' --publisher 'Microsoft.Azure.NetworkWatcher' --enable-auto-upgrade 'true' --version '1.4' --resource-group 'myResourceGroup' --vm-name 'myVM'
# Install Network Watcher Agent for Linux on the virtual machine.
az vm extension set --name 'NetworkWatcherAgentLinux' --extension-instance-name 'AzureNetworkWatcherExtension' --publisher 'Microsoft.Azure.NetworkWatcher' --enable-auto-upgrade 'true' --version '1.4' --resource-group 'myResourceGroup' --vm-name 'myVM'
Use the following Azure Resource Manager template (ARM template) to install the Network Watcher Agent VM extension on a virtual machine:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
}
},
"resources": [
{
"name": "[concat(parameters('vmName'), '/AzureNetworkWatcherExtension')]",
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2024-07-01",
"location": "[resourceGroup().location]",
"properties": {
"autoUpgradeMinorVersion": true,
"publisher": "Microsoft.Azure.NetworkWatcher",
"type": "NetworkWatcherAgentWindows",
"typeHandlerVersion": "1.4"
}
}
]
}
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
}
},
"resources": [
{
"name": "[concat(parameters('vmName'), '/AzureNetworkWatcherExtension')]",
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2024-07-01",
"location": "[resourceGroup().location]",
"properties": {
"autoUpgradeMinorVersion": true,
"publisher": "Microsoft.Azure.NetworkWatcher",
"type": "NetworkWatcherAgentLinux",
"typeHandlerVersion": "1.4"
}
}
]
}
You can use either Azure PowerShell or Azure CLI to deploy the Resource Manager template:
# Deploy the JSON template file using Azure PowerShell.
New-AzResourceGroupDeployment -ResourceGroupName 'myResourceGroup' -TemplateFile 'agent.json'
# Deploy the JSON template file using the Azure CLI.
az deployment group create --resource-group 'myResourceGroup' --template-file 'agent.json'
Update Network Watcher Agent VM extension
Check your extension version
You can check your extension version by using the Azure portal, the Azure CLI, or PowerShell.
Go to Extensions + applications of your VM in the Azure portal.
In the extensions list, check the Version column for AzureNetworkWatcherExtension. If a newer version is available, the Latest Version column shows (Update Available).
Use the Get-AzVM cmdlet to check the extension's installed version:
(Get-AzVM -ResourceGroupName 'myResourceGroup' -Name 'myVM' -Status).Extensions | Where-Object { $_.Name -eq 'AzureNetworkWatcherExtension' } | Select-Object Name, TypeHandlerVersion
Use the Get-AzVMExtensionImage cmdlet to find the latest available version of the extension for your VM's operating system and region:
Get-AzVMExtensionImage -Location '<region>' -PublisherName 'Microsoft.Azure.NetworkWatcher' -Type 'NetworkWatcherAgentWindows' | Sort-Object -Property { [Version]$_.Version } -Descending | Select-Object -First 1
Get-AzVMExtensionImage -Location '<region>' -PublisherName 'Microsoft.Azure.NetworkWatcher' -Type 'NetworkWatcherAgentLinux' | Sort-Object -Property { [Version]$_.Version } -Descending | Select-Object -First 1
Use the az vm get-instance-view command to check the extension's installed version:
az vm get-instance-view --resource-group 'myResourceGroup' --name 'myVM' --query "extensions[?name=='AzureNetworkWatcherExtension'].typeHandlerVersion" --output tsv
Use the az vm extension image list command to find the latest available version of the extension for your VM's operating system:
az vm extension image list --name 'NetworkWatcherAgentWindows' --publisher 'Microsoft.Azure.NetworkWatcher' --latest
az vm extension image list --name 'NetworkWatcherAgentLinux' --publisher 'Microsoft.Azure.NetworkWatcher' --latest
Note
The latest version of the Network Watcher extension is 1.4.4011.1.
Enable automatic upgrade
Automatic upgrade lets the Azure platform update the extension to the latest version without manual intervention. Use the following steps to check whether automatic upgrade is enabled, and to enable it if it's not.
Under Settings of your VM in the Azure portal, select Extensions + applications.
Select AzureNetworkWatcherExtension from the list of extensions, and check the Automatic upgrade status column.
If it shows Disabled, select Enable automatic upgrade from the toolbar.
Select Yes to confirm.
Use Get-AzVMExtension cmdlet to check whether automatic upgrade is enabled:
Get-AzVMExtension -ResourceGroupName 'myResourceGroup' -VMName 'myVM' -Name 'AzureNetworkWatcherExtension' | Select-Object Name, EnableAutomaticUpgrade
If EnableAutomaticUpgrade is False, use Set-AzVMExtension cmdlet to enable it:
Set-AzVMExtension -ResourceGroupName 'myResourceGroup' -VMName 'myVM' -Name 'AzureNetworkWatcherExtension' -Publisher 'Microsoft.Azure.NetworkWatcher' -ExtensionType 'NetworkWatcherAgentWindows' -EnableAutomaticUpgrade $true
Set-AzVMExtension -ResourceGroupName 'myResourceGroup' -VMName 'myVM' -Name 'AzureNetworkWatcherExtension' -Publisher 'Microsoft.Azure.NetworkWatcher' -ExtensionType 'NetworkWatcherAgentLinux' -EnableAutomaticUpgrade $true
Use the az vm extension show command to check whether automatic upgrade is enabled:
az vm extension show --resource-group 'myResourceGroup' --vm-name 'myVM' --name 'AzureNetworkWatcherExtension' --query 'enableAutomaticUpgrade'
If the command returns false, use the az vm extension set command to enable it:
az vm extension set --resource-group 'myResourceGroup' --vm-name 'myVM' --name 'NetworkWatcherAgentWindows' --publisher 'Microsoft.Azure.NetworkWatcher' --enable-auto-upgrade 'true'
az vm extension set --resource-group 'myResourceGroup' --vm-name 'myVM' --name 'NetworkWatcherAgentLinux' --publisher 'Microsoft.Azure.NetworkWatcher' --enable-auto-upgrade 'true'
Use the following Azure Resource Manager template (ARM template) to enable automatic upgrade on the Network Watcher Agent VM extension:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
}
},
"resources": [
{
"name": "[concat(parameters('vmName'), '/AzureNetworkWatcherExtension')]",
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2024-07-01",
"location": "[resourceGroup().location]",
"properties": {
"autoUpgradeMinorVersion": true,
"enableAutomaticUpgrade": true,
"publisher": "Microsoft.Azure.NetworkWatcher",
"type": "NetworkWatcherAgentWindows",
"typeHandlerVersion": "1.4"
}
}
]
}
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
}
},
"resources": [
{
"name": "[concat(parameters('vmName'), '/AzureNetworkWatcherExtension')]",
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2024-07-01",
"location": "[resourceGroup().location]",
"properties": {
"autoUpgradeMinorVersion": true,
"enableAutomaticUpgrade": true,
"publisher": "Microsoft.Azure.NetworkWatcher",
"type": "NetworkWatcherAgentLinux",
"typeHandlerVersion": "1.4"
}
}
]
}
You can use either Azure PowerShell or Azure CLI to deploy the Resource Manager template:
# Deploy the JSON template file using Azure PowerShell.
New-AzResourceGroupDeployment -ResourceGroupName 'myResourceGroup' -TemplateFile 'agent.json'
# Deploy the JSON template file using the Azure CLI.
az deployment group create --resource-group 'myResourceGroup' --template-file 'agent.json'
Note
After you enable automatic upgrade, Azure updates the extension automatically without requiring a restart of the virtual machine. This process can take up to 30 days after a new version is released.
Update manually
Under Settings of your VM in the Azure portal, select Extensions + applications.
Select AzureNetworkWatcherExtension from the list of extensions, and then select Update from the toolbar.
Select Yes to confirm.
When the update finishes, the Version and Latest Version columns show the same version number.
If updating doesn't apply the latest version, remove the extension and install it again:
- Select AzureNetworkWatcherExtension from the list of extensions, and then select Uninstall.
- Select + Add, search for Network Watcher Agent, and install it again. The platform automatically installs the latest available version. For more information, see Install Network Watcher Agent VM extension.
Use the Set-AzVMExtension cmdlet with the -ForceRerun parameter to reapply the extension without uninstalling it. The -ForceRerun value must be different from its current value each time you run the command, so use a value that changes, such as the current date and time:
Set-AzVMExtension -ResourceGroupName 'myResourceGroup' -VMName 'myVM' -Name 'AzureNetworkWatcherExtension' -Publisher 'Microsoft.Azure.NetworkWatcher' -Type 'NetworkWatcherAgentWindows' -ForceRerun (Get-Date -Format o)
Set-AzVMExtension -ResourceGroupName 'myResourceGroup' -VMName 'myVM' -Name 'AzureNetworkWatcherExtension' -Publisher 'Microsoft.Azure.NetworkWatcher' -Type 'NetworkWatcherAgentLinux' -ForceRerun (Get-Date -Format o)
If that condition doesn't update the extension, remove it and install it again to get the latest version:
Remove-AzVMExtension -ResourceGroupName 'myResourceGroup' -VMName 'myVM' -Name 'AzureNetworkWatcherExtension'
Set-AzVMExtension -ResourceGroupName 'myResourceGroup' -VMName 'myVM' -Name 'AzureNetworkWatcherExtension' -Publisher 'Microsoft.Azure.NetworkWatcher' -Type 'NetworkWatcherAgentWindows'
Set-AzVMExtension -ResourceGroupName 'myResourceGroup' -VMName 'myVM' -Name 'AzureNetworkWatcherExtension' -Publisher 'Microsoft.Azure.NetworkWatcher' -Type 'NetworkWatcherAgentLinux'
Use the az vm extension set command with the --force-update parameter to reapply the extension without uninstalling it:
az vm extension set --resource-group 'myResourceGroup' --vm-name 'myVM' --name 'NetworkWatcherAgentWindows' --publisher 'Microsoft.Azure.NetworkWatcher' --force-update
az vm extension set --resource-group 'myResourceGroup' --vm-name 'myVM' --name 'NetworkWatcherAgentLinux' --publisher 'Microsoft.Azure.NetworkWatcher' --force-update
If that condition doesn't update the extension, remove it and install it again to get the latest version:
az vm extension delete --resource-group 'myResourceGroup' --vm-name 'myVM' --name 'AzureNetworkWatcherExtension'
az vm extension set --resource-group 'myResourceGroup' --vm-name 'myVM' --name 'NetworkWatcherAgentWindows' --publisher 'Microsoft.Azure.NetworkWatcher'
az vm extension set --resource-group 'myResourceGroup' --vm-name 'myVM' --name 'NetworkWatcherAgentLinux' --publisher 'Microsoft.Azure.NetworkWatcher'
Use the following Azure Resource Manager template (ARM template) to reapply the extension. Update the typeHandlerVersion parameter to the latest version you identified in Check your extension version, and redeploy the template:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
},
"typeHandlerVersion": {
"type": "string"
}
},
"resources": [
{
"name": "[concat(parameters('vmName'), '/AzureNetworkWatcherExtension')]",
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2024-07-01",
"location": "[resourceGroup().location]",
"properties": {
"autoUpgradeMinorVersion": true,
"publisher": "Microsoft.Azure.NetworkWatcher",
"type": "NetworkWatcherAgentWindows",
"typeHandlerVersion": "[parameters('typeHandlerVersion')]"
}
}
]
}
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
},
"typeHandlerVersion": {
"type": "string"
}
},
"resources": [
{
"name": "[concat(parameters('vmName'), '/AzureNetworkWatcherExtension')]",
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2024-07-01",
"location": "[resourceGroup().location]",
"properties": {
"autoUpgradeMinorVersion": true,
"publisher": "Microsoft.Azure.NetworkWatcher",
"type": "NetworkWatcherAgentLinux",
"typeHandlerVersion": "[parameters('typeHandlerVersion')]"
}
}
]
}
You can use either Azure PowerShell or Azure CLI to deploy the Resource Manager template:
# Deploy the JSON template file using Azure PowerShell.
New-AzResourceGroupDeployment -ResourceGroupName 'myResourceGroup' -TemplateFile 'agent.json' -typeHandlerVersion '<version>'
# Deploy the JSON template file using the Azure CLI.
az deployment group create --resource-group 'myResourceGroup' --template-file 'agent.json' --parameters typeHandlerVersion='<version>'
Update at scale with a PowerShell script
If you have large deployments, use a PowerShell script to update multiple VMs in a subscription at once. The following script updates the Network Watcher extension on all out-of-date VMs in a subscription:
<#
.SYNOPSIS
This script scans all VMs in the provided subscription and upgrades any out-of-date AzureNetworkWatcherExtensions to the latest available version.
.DESCRIPTION
This script is a no-op if AzureNetworkWatcherExtensions are already up to date.
Requires Azure PowerShell 4.2 or higher to be installed.
.EXAMPLE
.\UpdateVMAgentsInSub.ps1 -SubID aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e -NoUpdate
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string] $SubID,
[Parameter(Mandatory=$false)]
[Switch] $NoUpdate = $false
)
function Get-LatestExtensionVersion($location, $extensionType)
{
$latestImage = Get-AzVMExtensionImage -Location $location -PublisherName "Microsoft.Azure.NetworkWatcher" -Type $extensionType |
Sort-Object -Property { [Version]$_.Version } -Descending |
Select-Object -First 1
return $latestImage.Version
}
Write-Host "Scanning all VMs in the subscription: $($SubID)"
Set-AzContext -SubscriptionId $SubID
$vms = Get-AzVM
$foundVMs = $false
Write-Host "Starting VM search, this may take a while"
foreach ($vmName in $vms)
{
# Get Detailed VM info
$vm = Get-AzVM -ResourceGroupName $vmName.ResourceGroupName -Name $vmName.name -Status
$isitWindows = $vm.OsName -like "*Windows*"
$type = if ($isitWindows) { "NetworkWatcherAgentWindows" } else { "NetworkWatcherAgentLinux" }
$latestVersion = Get-LatestExtensionVersion -location $vmName.Location -extensionType $type
foreach ($extension in $vm.Extensions)
{
if ($extension.Name -eq "AzureNetworkWatcherExtension")
{
if ([Version]$extension.TypeHandlerVersion -lt [Version]$latestVersion)
{
$foundVMs = $true
if (-not ($NoUpdate))
{
Write-Host "Found VM that needs to be updated: subscriptions/$($SubID)/resourceGroups/$($vm.ResourceGroupName)/providers/Microsoft.Compute/virtualMachines/$($vm.Name) -> Updating to $latestVersion " -NoNewline
Remove-AzVMExtension -ResourceGroupName $vm.ResourceGroupName -VMName $vm.Name -Name "AzureNetworkWatcherExtension" -Force
Write-Host "... " -NoNewline
Set-AzVMExtension -ResourceGroupName $vm.ResourceGroupName -Location $vmName.Location -VMName $vm.Name -Name "AzureNetworkWatcherExtension" -Publisher "Microsoft.Azure.NetworkWatcher" -Type $type -TypeHandlerVersion $latestVersion
Write-Host "Done"
}
else
{
Write-Host "Found $(if ($isitWindows) {"Windows"} else {"Linux"}) VM that needs to be updated to $($latestVersion): subscriptions/$($SubID)/resourceGroups/$($vm.ResourceGroupName)/providers/Microsoft.Compute/virtualMachines/$($vm.Name)"
}
}
}
}
}
if ($foundVMs)
{
Write-Host "Finished $(if ($NoUpdate) {"searching"} else {"updating"}) out of date AzureNetworkWatcherExtension on VMs"
}
else
{
Write-Host "All AzureNetworkWatcherExtensions up to date"
}
Uninstall Network Watcher Agent VM extension
From the virtual machine page in the Azure portal, you can uninstall the Network Watcher Agent VM extension by following these steps:
Under Settings, select Extensions + applications.
Select AzureNetworkWatcherExtension from the list of extensions, and then select Uninstall.
Note
You might see Network Watcher Agent VM extension named differently than AzureNetworkWatcherExtension.
Use the Remove-AzVMExtension cmdlet to remove the Network Watcher Agent VM extension from the virtual machine:
# Uninstall Network Watcher Agent VM extension.
Remove-AzVMExtension -Name 'AzureNetworkWatcherExtension' -ResourceGroupName 'myResourceGroup' -VMName 'myVM'
Use the az vm extension delete command to remove the Network Watcher Agent VM extension from the virtual machine:
# Uninstall Network Watcher Agent VM extension.
az vm extension delete --name 'AzureNetworkWatcherExtension' --resource-group 'myResourceGroup' --vm-name 'myVM'
Frequently asked questions (FAQ)
To get answers to the most frequently asked questions about Network Watcher Agent, see Network Watcher Agent FAQ.
Related content