In the Azure portal, I can check/enable VM Monitoring Insights:
In the portal, we can get a list of VMs that are monitored here: https://portal.azure.com/#view/Microsoft_Azure_Monitoring/AzureMonitoringBrowseBlade/~/virtualMachines
How can I, using the Python SDK (preferably) or the Azure CLI:
- Get a list of all VMs in a subscription that do not have this feature enabled?
- Enable Monitoring Insights?
2
Answers
I haven't been able to find an API call that gives me what I need in an obvious (to me) fashion.
However, calling az vm extension list/ComputeManagementClient.virtual_machine_extensions and checking if the AzureMonitorLinuxAgent or AzureMonitorWindowsAgent exists seems to correlate with the information we get in the Portal about whether the Monitoring Insights is active in a specific VM.
There are only below options to install
VM Insights
, refer the MS DOC for more details.Here is a PowerShell script to enable
VM
Insights features on allVMs
that are not already enabled in thesubscription
.Output:
After running the script, the
VM
Insights feature has been enabled on the VMsReference: Enable VM insights by using PowerShell
Check VMInsights on VMs