Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Az.OperationalInsights module could not be loaded #7

Open
timwhite-tesserent opened this issue May 9, 2024 · 1 comment
Open

Az.OperationalInsights module could not be loaded #7

timwhite-tesserent opened this issue May 9, 2024 · 1 comment

Comments

@timwhite-tesserent
Copy link

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
@cdranschak
Copy link

Do you have the Az.OperationalInsights module installed in your automation account?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants