Introduction:
In today’s fast-paced digital world, keeping track of changes and maintaining an accurate inventory of your virtual machines is crucial for efficient management and security. Azure Monitor Agent (AMA) offers a robust solution for change tracking and inventory management for both Azure Virtual Machines and Azure ARC Virtual Machines. This blog post will guide you through the process of setting up and utilizing AMA to ensure your virtual environment is always up-to-date and secure.
Create Azure Extension
Using the Azure Cloud Shell run this command on each VM to enable the extension on the virtual machine.
Linux:
az connectedmachine extension create --name ChangeTracking-Linux --publisher Microsoft.Azure.ChangeTrackingAndInventory --type-handler-version 2.20 --type ChangeTracking-Linux --machine-name (AzureArcVmName) --resource-group (ResourceGroupName) --location (AzureRegionName) --enable-auto-upgrade
Windows:
az connectedmachine extension create --name ChangeTracking-Windows --publisher Microsoft.Azure.ChangeTrackingAndInventory --type-handler-version 2.20 --type ChangeTracking-Windows --machine-name (AzureArcVmName) --resource-group (ResourceGroupName) --location (AzureRegionName) --enable-auto-upgrade
Create a Data Collection Rule:
Currently the easiest way to get this completed is to create a new Azure Virtual Machine and link this machine to Change Tracking. It will create the Data collection rule in the back end.
The other option to do this was to use a template but it seems to have some issues at this time of the post. Enable Azure Automation Change Tracking for single machine and multiple machines from the portal. | Microsoft Learn
- Create a new Azure Virtual Machine
- Create a new Log Analytics Workspace if one doesn’t already exist.
- The workspace was created in the same Resource Group as the virtual machine in this example.
- Go to Change Tracking of the new VM under the Operations blade.
Note: If there is no Log Analytics workspace a message will be displayed “checking permissions” which never completes. Cancel the form, add in a Log Analytics workspace and continue as shown below.
Watch for the notifications in the Azure Portal as the screen will not refresh.
Once this succeeds refresh the Azure Portal Page.
Go to Change Tracking again to see the form show. Once this is visible add in other Azure virtual machines and ARC resources.
Go to Azure Monitor and then Data Collection Rules.
🡪
A new resource starting with ct-dcr-xxxx should be available.
Click on this new data collection rule and select Resources add Azure virtual machines or Azure ARC machines.
Click the Add button.
DO NOT ADD DATA SOURCES TO THIS DATA COLLECTION RULE.
The schemas are not compatible and it will break the change tracking and inventory UI.
Once this is setup Change Tracking and Inventory of your Azure VM’s and ARC Enabled Machines should be visible.
Change Tracking:
Inventory:
Azure Documentation Reference: Enable Azure Automation Change Tracking for single machine and multiple machines from the portal. | Microsoft Learn
Conclusion:
By following the steps outlined in this guide, you can leverage the power of Azure Monitor Agent to effectively track changes and manage the inventory of your virtual machines. This not only enhances your operational efficiency but also strengthens your security posture. Stay ahead of the curve by implementing these best practices and ensure your virtual environment remains robust and resilient.