Install Azure Monitor Agent

Azure Monitor Agent is implemented as an Azure virtual machine (VM) extension. You can install Azure Monitor Agent by using any of the methods for installing virtual machine extensions, including those described in the Azure Monitor Agent overview article.

The following section covers installing Azure Monitor Agent on Azure Arc-enabled servers by using PowerShell and the Azure CLI. For more information, see Manage Azure Monitor Agent.

Use PowerShell

You can install Azure Monitor Agent on Azure virtual machines and on Azure Arc-enabled servers by using New-AzConnectedMachineExtension, the PowerShell cmdlet for adding a virtual machine extension.

Install on Azure Arc-enabled servers

Use the following PowerShell command to install Azure Monitor Agent on Azure Arc-enabled servers.

New-AzConnectedMachineExtension -Name AMAWindows -ExtensionType AzureMonitorWindowsAgent -Publisher Microsoft.Azure.Monitor -ResourceGroupName <resource-group-name> -MachineName <arc-server-name> -Location <arc-server-location>

Uninstall on Azure Arc-enabled servers

Use the following PowerShell command to uninstall Azure Monitor Agent from Azure Arc-enabled servers.

Remove-AzConnectedMachineExtension -MachineName <arc-server-name> -ResourceGroupName <resource-group-name> -Name AMAWindows

Upgrade on Azure Arc-enabled servers

To perform a one-time upgrade of the agent, use the following PowerShell commands.

$target = @{"Microsoft.Azure.Monitor.AzureMonitorWindowsAgent" = @{"targetVersion"=<target-version-number>}}
Update-AzConnectedExtension -ResourceGroupName $env.ResourceGroupName -MachineName <arc-server-name> -ExtensionTarget $target

Use the Azure CLI

You can install Azure Monitor Agent on Azure virtual machines and on Azure Arc-enabled servers by using the Azure CLI command for adding a virtual machine extension.

Install on Azure Arc-enabled servers

Use the following Azure CLI commands to install Azure Monitor Agent on Azure Arc-enabled servers.

az connectedmachine extension create --name AzureMonitorWindowsAgent --publisher Microsoft.Azure.Monitor --type AzureMonitorWindowsAgent --machine-name <arc-server-name> --resource-group <resource-group-name> --location <arc-server-location>

Uninstall on Azure Arc-enabled servers

Use the following Azure CLI commands to uninstall Azure Monitor Agent from Azure Arc-enabled servers.

az connectedmachine extension delete --name AzureMonitorWindowsAgent --machine-name <arc-server-name> --resource-group <resource-group-name>

Upgrade on Azure Arc-enabled servers

To perform a one time upgrade of the agent, use the following CLI commands:

az connectedmachine upgrade-extension --extension-targets "{\"Microsoft.Azure.Monitor.AzureMonitorWindowsAgent\":{\"targetVersion\":\"<target-version-number>\"}}" --machine-name <arc-server-name> --resource-group <resource-group-name>

Enable the Network Watcher agent

After your machine is Azure Arc-enabled, it's recognized as an Azure resource. After you enable the Azure Monitor Agent extension, install the Network Watcher extension. The process is similar to installing the Network Watcher extension in an Azure VM.

To make Connection Monitor recognize your Azure Arc-enabled on-premises machines with the Azure Monitor Agent extension as monitoring sources, install the Network Watcher agent virtual machine extension on them. This extension is also known as the Network Watcher extension. To install the Network Watcher extension on your Azure Arc-enabled servers with the Azure Monitor Agent extension installed, see Monitor network connectivity by using Connection Monitor.

You can also use the following command to install the Network Watcher extension in your Azure Arc-enabled machine with Azure Monitor Agent extension.

New-AzConnectedMachineExtension -Name AzureNetworkWatcherExtension -ExtensionType NetworkWatcherAgentWindows -Publisher Microsoft.Azure.NetworkWatcher -ResourceGroupName $rg -MachineName $vm -Location $location

Next steps

  • After you've installed the monitoring agents, create a connection monitor. Then, after you've created a connection monitor, analyze your monitoring data, set alerts, and diagnose issues in your connection monitor and your network.

  • Monitor the network connectivity of your Azure and non-Azure setups by using Connection Monitor.