Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.3k views
in Technique[技术] by (71.8m points)

powershell - Add a log analytics workspace to Azure VM without replacing existing workspaces

I have the following Powershell command

Set-AzVMExtension -ExtensionName "MicrosoftMonitoringAgent" `
                -ResourceGroupName "rg-xxxx" `
                -VMName "vm-xxxx" `
                -Publisher "Microsoft.EnterpriseCloud.Monitoring" `
                -ExtensionType "MicrosoftMonitoringAgent" `
                -TypeHandlerVersion "1.0" `
                -Settings @{"workspaceId" = "xxxx" } `
                -ProtectedSettings @{"workspaceKey" = "xxxx"} `
                -Location "uksouth"

which successfully replaces all Log Analytic Workspaces on the VM with the one I have configured in the command. What I want to do is only add the workspace without replacing the ones already configured.

ARM has the same behaviour. It looks like if there is one workspace already then this gets overwritten, if there are two workspaces there, one of them gets overwritten.

Does anyone know any method within Powershell to only add a workspace and not overwrite? Thanks, Neil.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

When we use the Log Analytics agent virtual machine extension to install Log Analytics agent on Azure VM, we just can enrolls virtual machines into one existing Log Analytics workspace. Every time we install the extension, Microsoft will replace the old configuration file. For more details, please refer to here.

If you want to add a workspace, please refer to the document


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...