Azure Automation Account: Error while unlinking the workspace
Hi All,
I was stumbling over a Azure Automation Account with a Linked workspace. I did get errors when trying to unlink the Workspace or delete the Azure Automation Account.
Unlink Workspace in the Azure Portal
Error Message:
An error occurred while unlinking the workspace. WorkspaceId: /subscriptions/42ecead4-eae9-4456-997c-1580c58b54ba/resourcegroups/loganalytics/providers/microsoft.operationalinsights/workspaces/aadloganalytics-icewolf. Error details: The link cannot be updated or deleted because it is linked to Update Management and/or ChangeTracking Solutions. Operation Id: '5a45c6618d8988953c1f15911857cbb6'. Error code: Linked Service is used by a solution..
It is probably due some of the depreciated Solutions is still active
- Inventory
- Change tracking
- Update Management
Let’s try to figure out with AZ PowerShell
Connect to Azure
Connect-AzAccount -Tenant icewolfch.onmicrosoft.com
List Azure Automation Account - not much to see here
Get-AzAutomationAccount -Name Automate-8023366-WEU -ResourceGroupName loganalytics
Took me a while to find the Linked Workspace
Get-AzOperationalInsightsLinkedService -ResourceGroupName loganalytics -WorkspaceName aadloganalytics-icewolf
Another way would be to use the Azure Rest API Linked Workspace - Get
$SubscriptionId = "42ecead4-eae9-4456-997c-1580c58b54ba"
$AutomationAccount = "Automate-8023366-WEU"
$ResourceGroup = "loganalytics"
$URL = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroup/providers/Microsoft.Automation/automationAccounts/$AutomationAccount/linkedWorkspace?api-version=2023-11-01"
Invoke-AzRest -Uri $URL
Now let’s find the Solutions. Seems like Update Management is still enabled
Get-AzOperationalInsightsIntelligencePacks -ResourceGroupName LogAnalytics -WorkspaceName aadloganalytics-icewolf | Sort-Object Name
Disable Update Management
Set-AzOperationalInsightsIntelligencePack -ResourceGroupName "LogAnalytics" -WorkspaceName "aadloganalytics-icewolf" -IntelligencePackName "Updates" -Enabled $false
List enabled Services
Get-AzOperationalInsightsIntelligencePacks -ResourceGroupName LogAnalytics -WorkspaceName aadloganalytics-icewolf | where-object {$_.Enabled -eq $True} | Sort-Object Name
Remove Linked Workspace
Remove-AzOperationalInsightsLinkedService -ResourceGroupName "loganalytics" -WorkspaceName "aadloganalytics-icewolf" -LinkedServiceName "Automation"
Check if there is a Linked Workspace - not anymore 😊
Get-AzOperationalInsightsLinkedService -ResourceGroupName loganalytics -WorkspaceName aadloganalytics-icewolf
Check in Azure Portal
Now i am able to remove the Automation Account
Remove-AzAutomationAccount -ResourceGroupName "loganalytics" -Name "Automate-8023366-WEU"
Regards
Andres Bohren