我想做一个自动化过程,其中每个虚拟机都应该与日志分析工作区连接。那么任何人都可以帮助我,我如何通过 REST API 或 Nodejs SDK 将虚拟机与日志分析工作区连接起来?
或
如何通过 REST API 或 Nodejs SDK 启用虚拟机洞察?
答案 0 :(得分:1)
如何通过 REST API 或 Nodejs SDK 启用虚拟机 Insight ?
您可以通过虚拟机扩展来实现,以启用以下 agents。
此外,在 Log Analytics 工作区可以用于 VM 洞察之前,它必须安装 VMInsights 解决方案。阅读Configuring VM insights。
例如,我点击此 REST API Virtual Machine Extensions - Create Or Update 中的绿色尝试按钮,并提供我的参数和正文以调用此 API。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}?api-version=2020-12-01
windows 虚拟机这样的请求正文将按顺序部署。
部署 MicrosoftMonitoringAgent
{
"location": "<location>",
"properties": {
"publisher": "Microsoft.EnterpriseCloud.Monitoring",
"type": "MicrosoftMonitoringAgent",
"typeHandlerVersion": "1.0",
"autoUpgradeMinorVersion": "true",
"settings": {
"workspaceId": "<workspaceId>",
"stopOnMultipleConnections": "true"
},
"protectedSettings": {
"workspaceKey": "<workspaceKey>"
}
}
}
一旦配置了上述扩展,您就可以部署 DependencyAgentWindows。
{
"location": "<location>",
"properties": {
"publisher": "Microsoft.Azure.Monitoring.DependencyAgent",
"type": "DependencyAgentWindows",
"typeHandlerVersion": "9.5",
"autoUpgradeMinorVersion": "true",
"settings": {
"workspaceId": "<workspaceId>"
},
"protectedSettings": {
"workspaceKey": "<workspaceKey>"
}
}
}