如何使用RESTAPI或Nodejs SDK将azure虚拟机与日志分析工作区连接?

如何使用RESTAPI或Nodejs SDK将azure虚拟机与日志分析工作区连接?,azure,azure-functions,azure-web-app-service,azure-virtual-machine,azure-log-analytics,Azure,Azure Functions,Azure Web App Service,Azure Virtual Machine,Azure Log Analytics,我想创建一个自动化流程,每个虚拟机都应该连接到日志分析工作区。因此,任何人都可以帮助我,我如何通过REST API或Nodejs SDK将VM与日志分析工作区连接起来? 或 如何通过REST API或Nodejs SDK启用virtual machine Insight? 如何通过RESTAPI或Nodejs SDK启用virtual machine Insight ? 您可以通过虚拟机扩展来实现以下功能 日志分析代理。和的VM扩展 依赖代理。和的VM扩展 此外,在日志分析工作区可以与VM

我想创建一个自动化流程,每个虚拟机都应该连接到日志分析工作区。因此,任何人都可以帮助我,我如何通过REST API或Nodejs SDK将VM与日志分析工作区连接起来?

如何通过REST API或Nodejs SDK启用virtual machine Insight?

如何通过RESTAPI或Nodejs SDK启用virtual machine Insight ?

您可以通过虚拟机扩展来实现以下功能

  • 日志分析代理。和的VM扩展
  • 依赖代理。和的VM扩展
此外,在日志分析工作区可以与VM insights一起使用之前,必须先安装VMInsights解决方案。阅读

例如,我单击此REST API中的绿色try it按钮,并提供调用此API的参数和主体

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}?api-version=2020-12-01
windows VM的请求主体将按顺序部署

部署MicrosoftMonitoringAgent

{
    "location": "<location>",
    "properties": {
        "publisher": "Microsoft.EnterpriseCloud.Monitoring",
        "type": "MicrosoftMonitoringAgent",
        "typeHandlerVersion": "1.0",
        "autoUpgradeMinorVersion": "true",
        "settings": {
            "workspaceId": "<workspaceId>",
            "stopOnMultipleConnections": "true"
        },
        "protectedSettings": {
            "workspaceKey": "<workspaceKey>"
        }
                    }

}
        
{
“地点”:“,
“财产”:{
“发布者”:“Microsoft.EnterpriseCloud.Monitoring”,
“类型”:“MicrosoftMonitoringAgent”,
“typeHandlerVersion”:“1.0”,
“autoUpgradeMinorVersion”:“true”,
“设置”:{
“工作空间ID”:“,
“stopOnMultipleConnections”:“true”
},
“protectedSettings”:{
“工作空间键”:”
}
}
}
一旦设置了上述扩展,就可以部署DependencyAgentWindow

{
    "location": "<location>",
    "properties": {
        "publisher": "Microsoft.Azure.Monitoring.DependencyAgent",
        "type": "DependencyAgentWindows",
        "typeHandlerVersion": "9.5",
        "autoUpgradeMinorVersion": "true",
        "settings": {
            "workspaceId": "<workspaceId>"
        },
        "protectedSettings": {
            "workspaceKey": "<workspaceKey>"
        }
                    }

}
{
“地点”:“,
“财产”:{
“发布者”:“Microsoft.Azure.Monitoring.DependencyAgent”,
“类型”:“DependencyAgentWindows”,
“typeHandlerVersion”:“9.5”,
“autoUpgradeMinorVersion”:“true”,
“设置”:{
“工作空间ID”:”
},
“protectedSettings”:{
“工作空间键”:”
}
}
}

嗨,南希,非常感谢你的宝贵帮助。是的,我已经实现了您维护的RESTAPI,它正在工作。现在我们可以动态地启用vm insight,现在我们静态地使用“workspaceKey”,但对于动态绑定,我们需要动态地知道“workspaceKey”。因此,请您帮助我们,使用任何REST api或nodejs sdk获取“workspaceKey”,以便我们可以动态配置它。嗨,Nancy,非常感谢您的宝贵帮助。是的,我已经实现了您维护的RESTAPI,它正在工作。现在我们可以动态地启用vm insight,现在我们静态地使用“workspaceKey”,但对于动态绑定,我们需要动态地知道“workspaceKey”。因此,请您帮助我们,使用任何REST api或nodejs sdk获取“workspaceKey”,以便我们动态配置。您可以通过Hi Nancy获取密钥,谢谢您的帮助。它工作正常,谢谢..嗨,Nancy,在上述解决方案的帮助下,我启用了VM Insights。现在我面临以下问题。你能帮我解决以下问题吗