Azure-docs: Report to multiple log analytics workspaces

Created on 8 Jan 2019  Â·  5Comments  Â·  Source: MicrosoftDocs/azure-docs

Hello, I would like to ask, if I understand it correctly.
Even so, that MMA agent (MS windows) is capable to join multiple workspaces, powershell cmd-let Set-AzureRmVMExtension is unable to configure that MMA agent correctly?

Thanks for info


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

cxp product-question triaged virtual-machines-windowsvc

Most helpful comment

@mchmelaroriflame - The Set-AzureRMVMExtension is only intended to install the VM Extension for Log Analytics agent and not configure it afterwards to report to another workspace or a different one. To do that you would use some PowerShell code, Azure Policy, or you could consider using Azure Automation DSC to accomplish this. The PowerShell code would look something like this -

$workspaceId = 'AddWorkspaceId'
$workspaceKey = 'AddWorkspacePriKey'

$mma = New-Object -ComObject 'AgentConfigManager.MgmtSvcCfg'

if ($mma.GetCloudWorkspace($workspaceId).workspaceid -ne $workspaceId)
{
    $mma.AddCloudWorkspace($workspaceId, $workspaceKey)
    $mma.ReloadConfiguration()
    $mma.GetCloudWorkspace($workspaceId).ConnectionStatusText
    Write-Verbose "Host $env:COMPUTERNAME is now configured for $workspaceId" -Verbose
}
else
{
    Write-Warning "Host $env:COMPUTERNAME already configured for $workspaceId"
}

Hope that helps.

All 5 comments

Thanks for the question! We are investigating and will update you shortly.

@roiyz-msft @@MGoedtel Can either of you please help confirm on this one? Thanks. :)
There are some comments about this in another GitHub issue as well.

@mchmelaroriflame - The Set-AzureRMVMExtension is only intended to install the VM Extension for Log Analytics agent and not configure it afterwards to report to another workspace or a different one. To do that you would use some PowerShell code, Azure Policy, or you could consider using Azure Automation DSC to accomplish this. The PowerShell code would look something like this -

$workspaceId = 'AddWorkspaceId'
$workspaceKey = 'AddWorkspacePriKey'

$mma = New-Object -ComObject 'AgentConfigManager.MgmtSvcCfg'

if ($mma.GetCloudWorkspace($workspaceId).workspaceid -ne $workspaceId)
{
    $mma.AddCloudWorkspace($workspaceId, $workspaceKey)
    $mma.ReloadConfiguration()
    $mma.GetCloudWorkspace($workspaceId).ConnectionStatusText
    Write-Verbose "Host $env:COMPUTERNAME is now configured for $workspaceId" -Verbose
}
else
{
    Write-Warning "Host $env:COMPUTERNAME already configured for $workspaceId"
}

Hope that helps.

please-close I'm going to bug this and make sure the article states you can only use this method for installing the agent and providing initial configuration and make reference to other methods for post-install config changes to agent.

@mchmelaroriflame Thanks for bringing this to our attention. We will now close this issue. If there are further questions regarding this matter, please tag me in a comment. I will reopen it and we will gladly continue the discussion.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

varma31 picture varma31  Â·  3Comments

bityob picture bityob  Â·  3Comments

spottedmahn picture spottedmahn  Â·  3Comments

ianpowell2017 picture ianpowell2017  Â·  3Comments

JeffLoo-ong picture JeffLoo-ong  Â·  3Comments