Reputation: 41
I want to make an automation process where every vm should connect with a log analytics workspace. So can anyone please help me, how do I connect a VM with log analytics workspace via REST API or Nodejs SDK ?
or
How do I enable virtual machine Insight through REST API or Nodejs SDK ?
Upvotes: 0
Views: 1329
Reputation: 28224
How do I enable virtual machine Insight through REST API or Nodejs SDK ?
You can manage to do it with virtual Machine Extensions to enable the following agents.
Also, Before a Log Analytics workspace can be used with VM insights, it must have the VMInsights solution installed. Read Configuring VM insights.
For example, I click the green try it button in this REST API Virtual Machine Extensions - Create Or Update and provide my parameters and body to call this API.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}?api-version=2020-12-01
The requests body like this for windows VM will be deployed in order.
Deploy MicrosoftMonitoringAgent
{
"location": "<location>",
"properties": {
"publisher": "Microsoft.EnterpriseCloud.Monitoring",
"type": "MicrosoftMonitoringAgent",
"typeHandlerVersion": "1.0",
"autoUpgradeMinorVersion": "true",
"settings": {
"workspaceId": "<workspaceId>",
"stopOnMultipleConnections": "true"
},
"protectedSettings": {
"workspaceKey": "<workspaceKey>"
}
}
}
Once the above extension is provisioned, you can deploy DependencyAgentWindows.
{
"location": "<location>",
"properties": {
"publisher": "Microsoft.Azure.Monitoring.DependencyAgent",
"type": "DependencyAgentWindows",
"typeHandlerVersion": "9.5",
"autoUpgradeMinorVersion": "true",
"settings": {
"workspaceId": "<workspaceId>"
},
"protectedSettings": {
"workspaceKey": "<workspaceKey>"
}
}
}
Upvotes: 1