-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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.Accounts v3.0.4 givimg warning in Azure Automation with PowerShell 5.1 runbooks #26155
Comments
@Shruti-MS - At what point do you get this error? We also started seeing a similar error in Azure Automation starting on 13th September 2024 - but we haven't updated Az.Accounts yet (still running v2.15.0).
Perhaps this is an Azure Automation issue? |
@Borgquite , Facing error since 13th Sept for 5.1 runbooks as image changed, eventually all runbooks run on v3.0.4 of Az.Accounts. If you are saying Az.Accounts version by seeing from modules tab it is wrong. You have to write in runbook Get-Module -listavailable, to get the Az.Accounts version currently used in runbook. |
@Shruti-MS Thank you for this post, I think it explains a lot of issues we are having. We are having this issue (we run PowerShell 5.1 in Azure Automation), and it shows Az. Accounts 2.15 in Modules tab but the verbose log shows it is still loading v3.0.4 as you described. Is there a way to prevent this behavior? This is concerning because there have been a lot of breaking issues lately and we depend on the automation account respecting the versions we have configured. Just a couple weeks ago we had to roll back our MSGraph and EXO modules to earlier versions due to another incompatibility issue with Az modules that broke modules in all of our environments (link below). Since Azure Automation did not offer an Az config newer than 11.2, we had to roll back the other 2 modules to get a working combination. It gave us a workaround for now, but it is concerning if the Az modules are potentially getting changed to run different versions than what is actually configured in the Modules tab without our knowledge until things start breaking. We don't run preview or beta modules in production, and it will likely be a while before there is a fix to these issues that will work in Azure Automation. microsoftgraph/msgraph-sdk-powershell#2803
|
@Shruti-MS Please you let us know when and where we should have found out about this (now clearly breaking) change, if you hadn’t made this post? Nothing here |
We see "Exception calling "Initialize" with "1" argument(s): "Object reference not set to an instance of an object."" too in our automation! We love the bugs like this too: microsoft/Microsoft365DSC#4720 😂 |
Same issue here with an automation acct and a powershell pipeline since updating to az.accounts 3.0.4 Despite the exception, my pipeline jobs are still completing I tried removing az.accounts 3.04 and install-module az.accounts -maximumversion 3.0.3 |
Can confirm 3.0.4 is actually used but cannot reproduce with either
|
Our analysis showed the most likely root cause is here https://github.com/isra-fel/azure-powershell/blob/513d6c028c5f87e881b3d7d7c0f95e6c81702a44/src/Accounts/Accounts/StartupScripts/InitializePSStyle.ps1#L3 when Az.Accounts is imported it tries to initialize some utilities related to styling, but unexpectedly To make sure the RCA is correct, I want to confirm with everyone if you all received warning messages, not errors? |
@isra-fel Yes, I’m receiving warnings. |
Yes, coming as warnings. |
Yes, warnings. |
@isra-fel, we have the same problem, with several Automation Accounts, but only with scripts using "Disable-AzContextAutosave -Scope Process" we get warnings like the OP, e.g. the following script snippet:
will produce the following output:
I can not repoduce this behaviour in a normal PS or CloudShell, but my guess would be "Disable-AzContextAutosave". |
We are able to find the root cause. This issue happens when Az.Accounts module is imported. That triggers the initialization of Based on the root cause analysis above, it's certain that this warning doesn't have any impact on the execution and the result of the runbook. We are talking to Azure Automation team to see if they can do something to prevent exception from being thrown. stack trace:
source code: |
@isra-fel Thanks - couldn't you suppress the warning inside Az.Accounts? |
I see, that Az.Accounts was downgraded from 3.0.4 to 2.15.0 on two Automation Acounts in the backend. So, the warning is gone for the time beeing. |
@eeode Yeah - except now if I try to use a Microsoft Graph call I get the following: Method not found: 'Void Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider..ctor(Azure.Core.TokenCredential, System.String[], Microsoft.Kiota.Authentication.Azure.ObservabilityOptions, System.String[])'. This error appeared in our Automation account at the precise same time as the Az account warnings came to an end. Come on Microsoft! This is as bad as the days of 'DLL Hell' in Windows 3.1. When on earth are you going to make your PowerShell modules play nicely together? And for the Automation team - why aren't you respecting the modules that we've selected in the Automation Modules any more, and why is there no notification that you're doing so? |
@Shruti-MS If we are running PowerShell 5.1 modules on Azure Automation, you have to give us the ability to control which module versions we use. It's a well known problem that comes up again and again - if Azure Automation keeps changing the Az module version that it uses behind the scenes, it'll be unusable microsoftgraph/msgraph-sdk-powershell#2148 |
Description
Azure Automation allows customers to run PowerShell scripts as runbooks. We recently published a new Docker image for PowerShell 5.1 with Az module version 11.2.0, which includes Az.Identity v3.0.4. After switching to this image, we started encountering a warning in the Connect-AzAccount cmdlet.
Reproduction Steps:
Connect-AzAccount -Identity
Exception calling "Initialize" with "1" argument(s): "Object reference not set to an instance of an object."
This warning does not occur when using Az.Accounts v2.15.0.
Issue script & Debug output
Environment data
Module versions
Error output
The text was updated successfully, but these errors were encountered: