Sometimes there are lots of VM in your subscriptions, it needs take long time to enable VM Insights in the Azure Portal.
You can view this blog to see how to get use of PowerShell script to enable all the VM with VM Insights to save your time.
- Prerequisites
- Networking Connectivity
Please ensure customer network allowing below internet outbound from the VM.
- *.ods.opinsights.azure.com
- *.oms.opinsights.azure.com
- *.blob.core.windows.net
- *.azure-automation.net
- Log Analytics Workspace
Please create at least one log analytics workspace for log storing.
- PowerShell Module
Please ensure your PowerShell have installed the latest module with Enable-AzureRM feature.
You may reference from here.
https://docs.microsoft.com/en-us/azure/azure-monitor/vm/vminsights-enable-powershell#prerequisites
- PowerShell Script
Please save the attached PowerShell script to your computer.
- Install-VMInsights
- Install-VMInsights-parameter
- Open the Install-VMInsights-parameter.
- Set the path that you save the Install-VMInsights.ps1
- Set the parameter.
- Tenant ID
- Subscription ID
- Workspace ID
- Workspace Key
- Workspace Region
- Resource Group Name (Optional)
*If you set the resource group name, the scope will be that specific resource group, rather than subscription.
- Open PowerShell as an administrator.
- Copy and run the script.
- It will list out all VM in the scope and require your confirmation.
- Press Y to confirm and it will start the installation.
- If there are any failed installation, it may cause by network connectivity or the OS compatibility. Please double check and confirm.
- VM Insight Agent upgrade
After the installation, we need to access the Azure portal and upgrade the agent.
- Go to Azure portal and open monitor
- Click Virtual Machine.
- You are able to see the VM insight agent status from here.
- If you confirm the machine are show as monitored, please select all and click Upgrade selected.
4. It will show a list to you.
- Click Upgrade to continue.
- When all process finishes, you may able to see the Monitor Coverage is Enabled and Guest VM Health is Healthy.
- Reference
https://docs.microsoft.com/en-us/azure/azure-monitor/vm/vminsights-enable-powershell
https://docs.microsoft.com/en-us/azure/azure-monitor/vm/vminsights-enable-portal
You can visit our SOS GitHub for downloading the source code as a template:
https://github.com/SOSHKMVP/Azure-Monitor/tree/main/Enable%20Az%20monitor%20-%20VM%20Insight
Eric Chan
Microsoft MVP
SOS Group Limited