如何将 Azure Scaleset 添加到 Log Analytics

How to add Azure Scaleset to Log Analytics

如何将 Azure 规模集添加到日志分析。从日志分析中我可以看到虚拟机,但与虚拟机不同的是,连接按钮未启用。我需要做什么。启用此连接。

关于此问题的 MSDN post:

https://blogs.msdn.microsoft.com/timomta/2018/04/09/how-to-add-the-oms-client-to-a-vm-scale-set/

如 post 中所述,我们解释了如何为 VM 而不是 VMSS 执行此操作。您可以通过 PowerShell 完成此操作,上面的 linked 博客描述了如何实现它。

我将为不想遵循 link

的用户添加下面的脚本
select-azurermsubscription -subscriptionid ‘your subscription id’
$PublicSettings = @{"workspaceId" = "your oms workspace id"}
$ProtectedSettings = @{"workspaceKey" = "your big base64 oms key"}

# Get information about the scale set
$vmss = Get-AzureRmVmss -ResourceGroupName 'VMSSRESOURCEGROUP' `
-VMScaleSetName 'VMSSNAME'

Add-AzureRmVmssExtension `
-VirtualMachineScaleSet $vmss `
-Name "Microsoft.EnterpriseCloud.Monitoring" `
-Publisher "Microsoft.EnterpriseCloud.Monitoring" `
-Type "MicrosoftMonitoringAgent" `
-TypeHandlerVersion 1.0 `
-AutoUpgradeMinorVersion $true `
-Setting $PublicSettings `
-ProtectedSetting $ProtectedSettings

# Update the scale set and apply the Custom Script Extension to the VM instances
Update-AzureRmVmss `
-ResourceGroupName $vmss.ResourceGroupName `
-Name $vmss.Name `
-VirtualMachineScaleSet $vmss

# Only needed for manual update VMSS – warning tells them all to update, so modify to suit
$jobs=@()
Get-AzureRmVmssVM -ResourceGroupName $vmss.ResourceGroupName -VMScaleSetName $vmss.Name | foreach {
$jobs+=Update-AzureRmVmssInstance -ResourceGroupName $vmss.ResourceGroupName -Name $vmss.Name -InstanceId $_.InstanceId -AsJob
}

$jobs | Wait-Job
$jobs | Receive-Job

感谢作者https://social.msdn.microsoft.com/profile/Tim+Omta