Share via


How to unlink an automation account that is linked to an OMS workspace?

Question

Friday, October 21, 2016 12:31 PM

I want to delete an automation account, but I get an error saying that "An error occurred while deleting the Automation account named 'xxxxxx'. Error details: Conflict: Automation account is linked to a workspace."

How can I unlink/delete the link between the automation account and the OMS workspace? I have deleted the solutions using the account (Change tracking and update management). 

All replies (10)

Monday, January 9, 2017 9:53 PM âś…Answered | 3 votes

You can unlink using PowerShell:

# if you are not connected to Azure run the next command to login
Login-AzureRmAccount

$workspaceId = "your workspace id (a guid) copied from the portal"

$automationSolutions = "Updates", "ChangeTracking", "AzureAutomation"
$automationAccount = ""

$workspace = (Get-AzureRmOperationalInsightsWorkspace).Where({$_.CustomerId -eq $workspaceId})

if (! $workspace ) {
    $subs = Get-AzureRmSubscription

    if ($subs.Count -gt 1) {
        $subs
        Write-Error "You have access to multiple subscriptions. Run Select-AzureRmSubscription to select the subscription with your workspace."
    } else {
        Write-Error "WorkspaceId not found: $workspaceId"
    }
    return
}

# If there is a linked automation account, remove the Automation and Control solutions
# unlink the automation account
try {
    $automationAccount = Get-AzureRmResource -ResourceId ($workspace.ResourceId + "/linkedServices/automation") -ErrorAction Stop
    }
catch {
    # continue
}

if ( $automationAccount ) {
    $enabledautomationSolutions = (Get-AzureRmOperationalInsightsIntelligencePacks -ResourceGroupName $workspace.ResourceGroupName -WorkspaceName $workspace.Name).Where({$_.Name -in $AutomationSolutions -and $_.Enabled -eq $true})
    foreach ($soln in $enabledAutomationSolutions.Name) {
        Set-AzureRmOperationalInsightsIntelligencePack -ResourceGroupName $workspace.ResourceGroupName -WorkspaceName $workspace.Name -IntelligencePackName $soln -Enabled $false
    }
    Remove-AzureRmResource -ResourceId $automationAccount.ResourceId
}

If you are not familiar with using PowerShell to manage Azure resources, the following documentation provides more information, including a link to Install and configure Azure PowerShell https://docs.microsoft.com/powershell/

You will soon be able to do this from the Azure portal, using the following steps:

  1. Remove from the Log Analytics workspace the Change Tracking, Update Management and Automation solutions (if enabled)
  2. Navigate to the Automation Account that is linked to a Log Analytics workspace
  3. Select the Overview node
  4. Click the Unlink Workspace command (this is currently not available and the tool tip shows 'coming soon')

This posting is provided "AS IS" with no warranties, and confers no rights.


Friday, November 11, 2016 2:09 PM

Hi fthing

I have the same problem. Did you find a solution?


Wednesday, November 16, 2016 8:48 PM

Can you guys send me your workspace IDs to the email address satyavel@microsoft<dot>com. I will try and take care of it in the backend. The UI support to do this is coming in December.


Monday, November 21, 2016 1:52 AM

Hi Satya,

I have the same problem too. I will draft email to you soon. Thanks.


Friday, November 25, 2016 1:14 AM

Hi Satya,

Does the same apply for O365 "linkage"?

Casper Pieterse - Snr. Solution Architect - Dimension Data


Wednesday, November 30, 2016 10:24 PM

If you open support tickets for this in the Azure portal CSS can address these issues very easily.

Steve Chilcoat


Friday, January 6, 2017 3:58 PM

Hi,

Has it been solved? I am not able to find how to unlink or how to change automation account from current workspace?

Thank you,

Martynas


Wednesday, August 9, 2017 10:13 AM

I am trying to deploy update Management Solution in OMS , with ARM Template. but creating an OMS workspace, Automation account, adding update management solution doesnt link the automation account to OMS workspace. please guide how to link OMS workspace with automation account. i created both oms workspace and automation account in to the same resource group and location. Adding Update Management solution from the OMS portal does link the OMS workspace and automation account. but the same is not achieved using ARM Template


Wednesday, August 9, 2017 10:33 AM

Select the automation account -> settings ->Related Resources -> Unlink Workspaces


Monday, July 16, 2018 7:00 AM

I am giving workspace id in query and automation account name and query executed without any error. But still not able to delete automation account. 

Please help

Cheers, Gourav Please remember to mark the replies as answers if it helped.