update-ama.ps1 is a PowerShell script you can use to update the Azure Monitor Agent on Azure Virtual Machines and Azure Arc Machines. The script will handle both Linux and Windows servers with the below features.
- Update the Azure Monitor Agent to a specific version
- Update the Azure Monitor Agent to the latest version
- Report on current versions without updating
I have also written a universal extension upgrade script that can be used to upgrade any extension: update-extension.ps1
Usage
- Azure Arc does not return a detailed status of the update request - The rest API only allows upgrading to Major.Minor versions. Therefore, you can't upgrade from 1.2 to 1.2.2 as an example, only to 1.3
- The script takes input from an object of machines from either Get-AzVM or Get-AzConnectedMachine. This will give you the flexibility to scope updates to specific machines.
- You can specify the versions you want to update to using the linuxTargetVersion and windowsTargetVersion parameters.
- To get a list of versions see Azure Monitor agent extension versions
- If you specify the latestVersion parameter the script will automatically use the latest version available in the region where the machine resides.
- If you specify the report parameter the script will only report on versions installed and will not update
Examples
Azure Virtual Machines
Update Azure Virtual Machines to a specific version
.\update-ama.ps1 -machines $(Get-AzVM) -linuxTargetVersion 1.22.2 -windowsTargetVersion 1.10.0.0
Update Azure Virtual Machines to the latest version of Windows and Linux
.\update-ama.ps1 -machines $(Get-AzVM) -latestVersion
Generate a report of Azure Virtual Machines with current versions
.\update-ama.ps1 -machines $(Get-AzVM) -latestVersion -report
Azure Arc Machines
Update Azure Arc Machines to a specific version
.\update-ama.ps1 -machines $(Get-AzConnectedMachine) -linuxTargetVersion 1.22.2 -windowsTargetVersion 1.10.0.0
Update Azure Arc Machines to the latest version of Windows and Linux
.\update-ama.ps1 -machines $(Get-AzConnectedMachine) -latestVersion
Generate a report of Azure Arc Machines with current versions
.\update-ama.ps1 -machines $(Get-AzConnectedMachine) -latestVersion -report