แก้ไข

แชร์ผ่าน


Install and upgrade Azure Monitor Agent on Azure Arc-enabled servers

Azure Monitor Agent is implemented as an Azure virtual machine (VM) extension. You can install Azure Monitor Agent using any of the methods described in Azure Monitor Agent overview.

This article covers installing Azure Monitor Agent on Azure Arc-enabled servers using PowerShell or 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 step