-
Notifications
You must be signed in to change notification settings - Fork 2
Description
When I run this runbook in my Azure Automation Account, I get the below error which displays that the Az.OperationalInsights module can not be loaded.
This runbook was created using the "Migrate now" option in Update Management.
Runbook type: PowerShell
Runtime Environment: PowerShell-5.1
Write-Telemetry : Unhandled exception [Debug]Command [ Set-AzContext -Subscription $armComponents.Subscription $Workspace = Get-AzOperationalInsightsWorkspace -ResourceGroupName $armComponents.ResourceGroup -Name $armComponents.ResourceName $QueryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $Workspace.CustomerId -Query $MachinesOnboaredToAutomationUpdateManagementQuery -ErrorAction Stop return $QueryResults ] failed even after [3] retries. Exception message:The 'Get-AzOperationalInsightsWorkspace' command was found in the module 'Az.OperationalInsights', but the module could not be loaded. For more information, run 'Import-Module Az.OperationalInsights'... At line:1678 char:9 + Write-Telemetry -Message ("Unhandled exception {0}." -f, $_.E ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-Telemetry
Full output here:
09/05/2024, 4:02:26 pm - Verbose: Successfully connected with account ****** to subscription ******
09/05/2024, 4:02:26 pm - Verbose: [Debug]Invoke-AzRestMethod started with params [@{Path=/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//linkedWorkspace?api-version=2022-08-08; Method=GET}]. Retry: 1./3
09/05/2024, 4:02:27 pm - Verbose: [Debug]Invoke-AzRestMethod with params [@{Path=/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//linkedWorkspace?api-version=2022-08-08; Method=GET}] succeeded. Output: [@{Headers=System.Object[]; Version=1.1; StatusCode=200; Method=GET; Content={"id":"/subscriptions//resourceGroups//providers/Microsoft.OperationalInsights/workspaces/defaultworkspace-4dc3ade2-ccc8-4732-9401-86790095834d-ase"}}].
09/05/2024, 4:02:27 pm - Verbose: [Debug]Command [
Set-AzContext -Subscription $armComponents.Subscription
$Workspace = Get-AzOperationalInsightsWorkspace -ResourceGroupName $armComponents.ResourceGroup -Name $armComponents.ResourceName
$QueryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $Workspace.CustomerId -Query $MachinesOnboaredToAutomationUpdateManagementQuery -ErrorAction Stop
return $QueryResults
] started. Retry: 1./3
09/05/2024, 4:02:29 pm - Warning: [Debug]Command [
Set-AzContext -Subscription $armComponents.Subscription
$Workspace = Get-AzOperationalInsightsWorkspace -ResourceGroupName $armComponents.ResourceGroup -Name $armComponents.ResourceName
$QueryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $Workspace.CustomerId -Query $MachinesOnboaredToAutomationUpdateManagementQuery -ErrorAction Stop
return $QueryResults
] failed. Retrying in 5 seconds, exception message:The 'Get-AzOperationalInsightsWorkspace' command was found in the module 'Az.OperationalInsights', but the module could not be loaded. For more information, run 'Import-Module Az.OperationalInsights'..
09/05/2024, 4:02:34 pm - Verbose: [Debug]Command [
Set-AzContext -Subscription $armComponents.Subscription
$Workspace = Get-AzOperationalInsightsWorkspace -ResourceGroupName $armComponents.ResourceGroup -Name $armComponents.ResourceName
$QueryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $Workspace.CustomerId -Query $MachinesOnboaredToAutomationUpdateManagementQuery -ErrorAction Stop
return $QueryResults
] started. Retry: 2./3
09/05/2024, 4:02:35 pm - Warning: [Debug]Command [
Set-AzContext -Subscription $armComponents.Subscription
$Workspace = Get-AzOperationalInsightsWorkspace -ResourceGroupName $armComponents.ResourceGroup -Name $armComponents.ResourceName
$QueryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $Workspace.CustomerId -Query $MachinesOnboaredToAutomationUpdateManagementQuery -ErrorAction Stop
return $QueryResults
] failed. Retrying in 15 seconds, exception message:The 'Get-AzOperationalInsightsWorkspace' command was found in the module 'Az.OperationalInsights', but the module could not be loaded. For more information, run 'Import-Module Az.OperationalInsights'..
09/05/2024, 4:02:50 pm - Verbose: [Debug]Command [
Set-AzContext -Subscription $armComponents.Subscription
$Workspace = Get-AzOperationalInsightsWorkspace -ResourceGroupName $armComponents.ResourceGroup -Name $armComponents.ResourceName
$QueryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $Workspace.CustomerId -Query $MachinesOnboaredToAutomationUpdateManagementQuery -ErrorAction Stop
return $QueryResults
] started. Retry: 3./3
09/05/2024, 4:02:51 pm - Error: Write-Telemetry : Unhandled exception [Debug]Command [
Set-AzContext -Subscription $armComponents.Subscription
$Workspace = Get-AzOperationalInsightsWorkspace -ResourceGroupName $armComponents.ResourceGroup -Name
$armComponents.ResourceName
$QueryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $Workspace.CustomerId -Query
$MachinesOnboaredToAutomationUpdateManagementQuery -ErrorAction Stop
return $QueryResults
] failed even after [3] retries. Exception message:The 'Get-AzOperationalInsightsWorkspace' command was found in
the module 'Az.OperationalInsights', but the module could not be loaded. For more information, run 'Import-Module
Az.OperationalInsights'...
At line:1678 char:9
-
Write-Telemetry -Message ("Unhandled exception {0}." -f, $_.E ...
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
- FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-Telemetry