This code uninstalls the Microsoft Monitoring agent and re-installs it to a new WorkSpace.
# change your VM Name and it's resource group $vm = get-azurermvm -VMName YourVMName -ResourceGroupName VMResourceGroup Remove-AzureRmVMExtension -ResourceGroupName $vm.ResourceGroupName -VMName $vm.Name -Name MicrosoftMonitoringAgent -Force # put in your new workspaceId & workspaceKey $workspaceId = "NewWorksSpaceID" $workspaceKey = "SupaSecretKey" $PublicSettings = @{"workspaceId" = $workspaceId;"stopOnMultipleConnections" = $false} $ProtectedSettings = @{"workspaceKey" = $workspaceKey} Set-AzureRmVMExtension -ExtensionName "MicrosoftMonitoringAgent" -ResourceGroupName $vm.resourcegroupname -VMName $vm.name ` -Publisher "Microsoft.EnterpriseCloud.Monitoring" ` -ExtensionType "MicrosoftMonitoringAgent" ` -TypeHandlerVersion 1.0 ` -Settings $PublicSettings ` -ProtectedSettings $ProtectedSettings ` -Location $vm.Location
Nothing special, just thought I would put it here. Mayby it will help someone?
Needed a quick fix as via the portal I could not get it done. This helped me in the right direction.
But above only works if your current extensionname is MicrosoftMonitoringtAgent, in my case it was MMAExtension.
So better to do get-AzureRmVMEXtension first (and move the whole thing to the new AZ module)
Thanks you very much. It helped me a lot.
Simple, but helpful to reference your post. Thanks!