Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.9k 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...