Share via


How to reassign VM insights to another Log Analytics workspace?

Question

Monday, April 22, 2019 4:03 PM

When enabling VM insights, I accidentally let it create a new log analytics workspace instead of using an existing one I wanted to use instead. Now I can't find any options anywhere to change which log analytics workspace it connects to. It doesn't even seem to be possible to disable/remove/delete VM insights so I can redo it with the correct log analytics workspace. How do I fix this?

All replies (5)

Wednesday, April 24, 2019 5:17 PM ✅Answered | 1 vote

I managed to do this; however I had to delete all of the VM Insights related extensions from the VM; there were 3 total.


Tuesday, April 23, 2019 9:30 AM

  • Go to Log Analytics > Select the workspace the VM is reporting to > Virtual Machines >  Disconnect.
  • Go to Log Analytics > Select the workspace you want the VM to report to > Virtual Machines > Connect.

Tuesday, April 23, 2019 9:36 AM

Hi Innovapost Sandbox, You may check Azure VM is connected to which Log Analytics workspace by going to Azure Portal -> ANYLOGANALYTICSWORKSPACE -> Workspace Data Sources tile -> Virtual Machines -> Search for your intended VM and click on it -> The value shown corresponding to Workspace Name parameter is the Log Analytics workspace to which your Azure VM is connected to.

One other easy way of finding this is using Azure PowerShell cmdlet Get-AzVMExtension / Get-AzureRMVMExtension as illustrated in below screenshot which has an output parameter called as workspace ID which is unique for each Log Analytics workspaces.

To disconnect / connect / change / reassign to another Log Analytics workspce you may use Azure PowerShell cmdlets Set-AzVMExtension / Remove-AzVMExtension / Set-AzureRMVMExtension / Remove-AzureRMVMExtension as illustrated here

Or you may do the same in Azure portal from Azure Portal -> YOURLOGANALYTICSWORKSPACE -> Workspace Data Sources tile -> Virtual Machines -> Disconnect / Connect based on the requirement.

Hope this helps!! Cheers!!


Wednesday, April 24, 2019 3:16 PM

It didn't work. I tried using the Remove-AzVMExtension cmdlet and I tried from the Azure portal, both times it didn't disconnect.

Output of the cmdlet:

PS Azure:\ Remove-AzureRmVMExtension -ResourceGroupName az-rtmnpd-rg-dev01 -VMName CRNPDEV1AIO0001 -Name ‘MicrosoftMonitoringAgent’

Virtual machine extension removal operation
This cmdlet will remove the specified virtual machine extension. Do you want to continue?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y

RequestId IsSuccessStatusCode StatusCode ReasonPhrase

                         True  NoContent No Content

When I tried doing it from the portal as you suggested, it said "Disconnecting" and to check back later, but when  I did, it's still connected.


Friday, April 26, 2019 5:13 AM

Thanks for the update! Glad to hear it is resolved :)