Enable VM insights using Resource Manager templates

This article describes how to enable VM insights for a virtual machine or Virtual Machine Scale Set using Resource Manager templates. This procedure can be used for:

  • Azure virtual machines
  • Azure Virtual Machine Scale Sets
  • Hybrid virtual machines connected with Azure Arc

If you aren't familiar with how to deploy a Resource Manager template, see Deploy templates.

Prerequisites

Resource Manager templates

Use the Azure Resource Manager templates provided in this article to onboard virtual machines and Virtual Machine Scale Sets using Azure Monitor agent and Log Analytics agent. The templates install the required agents and perform the configuration required to onboard to machine to VM insights.

Note

Deploy the template in the same resource group as the virtual machine or virtual machine scale set being enabled.

Enable VM insights using Azure Monitor Agent

First deploy the data collection rule, and then install agents to use that data collection rule.

Deploy data collection rule

This step installs a data collection rule, named MSVMI-{WorkspaceName}, in the same resource group as your Log Analytics workspace:

  1. Download the VM insights data collection rule templates.

  2. Deploy a template from the downloaded zip file. The following table describes the templates available:

    Folder File Description
    DeployDcr\
    PerfAndMapDcr
    DeployDcrTemplate
    DeployDcrParameters
    Enable both Performance and Map experience of VM Insights.
    DeployDcr\
    PerfOnlyDcr
    DeployDcrTemplate
    DeployDcrParameters
    Enable only Performance experience of VM Insights.

Deploy agents to machines

After you create the data collection rule, deploy:

Note

If your virtual machines scale sets have an upgrade policy set to manual, VM insights will not be enabled for instances by default after installing the template. You must manually upgrade the instances.

Enable VM insights using Log Analytics agent

Download the Logs Analytics agent templates. You must first configure the workspace and can then install agents to use that DCR.

Configure workspace

You only need to perform this step once for each workspace that will use VM insights.

Folder File Description
ConfigureWorkspace ConfigureWorkspaceTemplate.json
ConfigureWorkspaceParameters
Install VMInsights solution required for the workspace.

Deploy agents to machines

Once the workspace has been configured, deploy the agents using one of the templates in the following table. Templates are available that apply to an existing machine or create a new machine enabled for VM insights.

Folder File Description
NewVmOnboarding NewVmOnboardingTemplate.json
NewVmOnboardingParameters.json
Creates a virtual machine and enables it to be monitored with VM insights.
ExistingVmOnboarding ExistingVmOnboarding.json
ExistingVmOnboarding.json
Enables VM insights on existing virtual machine.
NewVmssOnboarding NewVmssOnboarding.json
NewVmssOnboarding.json
Creates a Virtual Machine Scale Set and enables it to be monitored with VM insights.
ExistingVmssOnboarding ExistingVmssOnboarding.json
ExistingVmssOnboarding.json
Enables VM insights on existing Virtual Machine Scale Set.
ExistingArcVmOnboarding ExistingArcVmOnboarding.json
ExistingArcVmOnboarding.json
Enables VM insights on existing Arc-enabled server.

Deploy templates

Each folder in the download has a template and a parameters file. Modify the parameters file with required details such as Virtual Machine Resource ID, Workspace resource ID, data collection rule resource ID, Location, and OS Type. Don't modify the template file unless you need to customize it for your particular scenario.

Deploy with the Azure portal

See Quickstart: Create and deploy ARM templates by using the Azure portal for details on deploying a template from the Azure portal.

Deploy with PowerShell

Use the following command to deploy the template with PowerShell.

New-AzResourceGroupDeployment -Name OnboardCluster -ResourceGroupName <ResourceGroupName> -TemplateFile <Template.json> -TemplateParameterFile <Parameters.json>

Azure CLI

Use the following command to deploy the template with Azure CLI.

az login
az account set --subscription "Subscription Name"
az deployment group create --resource-group <ResourceGroupName> --template-file <Template.json> --parameters <Parameters.json>

Next steps

Now that monitoring is enabled for your virtual machines, this information is available for analysis with VM insights.