Azure Automation Accounts Az.Accounts PowerShell module broken?

Philipp Durrer 10 Reputation points
2024-06-05T07:49:32.5366667+00:00

Since May 31st 2024 mid day UTC I see all our PowerShell 7.1 Runtime jobs failing due to the following error:

Failed
Write-Error: C:\usr\src\tmp\accaf8e0-f99e-4d6b-8a7f-47b42ff95a77\runbooks\StartStop-AKS.ps1:223
Line |
 223 |              StopStartAksCluster
     |              ~~~~~~~~~~~~~~~~~~~
     | System.IO.FileLoadException: Could not load file or assembly
     | 'Microsoft.ApplicationInsights, Version=2.18.0.315,
     | Culture=neutral, PublicKeyToken=31bf3856ad364e35'.    at
     | System.Management.Automation.Runspaces.InitialSessionState.Bind_LoadAssemblies(ExecutionContext context)    at System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly, PSModuleInfo module, Boolean noClobber, Boolean local, Boolean setLocation)    at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath, ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable localizedData, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModuleOptions& options, Boolean& containedErrors)

Write-Error: C:\usr\src\tmp\accaf8e0-f99e-4d6b-8a7f-47b42ff95a77\runbooks\StartStop-AKS.ps1:223
Line |
 223 |              StopStartAksCluster
     |              ~~~~~~~~~~~~~~~~~~~
     | System.IO.FileLoadException: Could not load file or assembly
     | 'Microsoft.ApplicationInsights, Version=2.18.0.315,
     | Culture=neutral, PublicKeyToken=31bf3856ad364e35'.    at
     | System.Management.Automation.Runspaces.InitialSessionState.Bind_LoadAssemblies(ExecutionContext context)    at System.Management.Automation.Runspaces.InitialSessionState.Bind(ExecutionContext context, Boolean updateOnly, PSModuleInfo module, Boolean noClobber, Boolean local, Boolean setLocation)    at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath, ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable localizedData, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModuleOptions& options, Boolean& containedErrors)

OperationStopped: C:\usr\src\tmp\accaf8e0-f99e-4d6b-8a7f-47b42ff95a77\runbooks\StartStop-AKS.ps1:149
Line |
 149 |          throw $_.Exception
     |          ~~~~~~~~~~~~~~~~~~
     | Could not load file or assembly
     | 'Microsoft.ApplicationInsights, Version=2.18.0.315,
     | Culture=neutral, PublicKeyToken=31bf3856ad364e35'.


My script is basically trying to do the following:

        #Inizialiting connection to the AutomationAccount
        try
        {
            Import-Module Az.Accounts
            "Logging in to Azure using Managed Identity..."
            Connect-AzAccount -Identity
        }

It looks like it doesn't matter the PowerShell version nor if I use a custom Runtime Environment or not everything fails. It's as if the Automation Account execution environment changed architecture and still tries to import the x64 modules.

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,173 questions
{count} votes