-
Notifications
You must be signed in to change notification settings - Fork 4k
Not able to connect to Azure with Az.Accounts version 2.12.3 (get_SerializationSettings) from within Visual studio code / Azure Automation runbook on Hybrid Worker #21960
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
Comments
Can confirm. Have the same problem. |
Same here |
Ditto... |
Same here. It fails i Terminal as well PSVersion 5.1.22621.963 |
Hi thanks for reporting. We are aware of this compatibility issue and are working with PowerShell to get it fixed. Let me summarize the problem here: SymptomThe Windows PowerShell 5.1 terminal provided by the PowerShell VS Code extension cannot import Az.Resources v6.6.1. The error you receive is: "Register-AzModule : The type initializer for 'Microsoft.Azure.Commands.Common.AzModule' threw an exception". Root causeThe Windows PowerShell 5.1 runtime preloads the PowerShellEditorServices module, which depends on Newtonsoft.Json 11.0. This issue is similar to one that caused a conflict with Az.Accounts. Workarounds
SolutionWe have contacted the team who maintains the PowerShellEditorServices module for an update of the library. According to them, it is inherited from the OmniSharp library that provides our LSP layer. We are in the process of following up with Omnisharp, which is part of .NET foundation. |
Is it possible that it doesn't work in PS7 ?
I had to downgrade the two mentioned Az modules (Az.Accounts v2.12.1, Az.Resources v6.6.0) to make it work. |
Can't wait to upgrade to PowerShell 7.0 to leave the nightmare of the newtonsoft dll. See as well https://learn.microsoft.com/en-us/powershell/scripting/dev-cross-plat/resolving-dependency-conflicts?view=powershell-7.3. However Azure Automation only support 5.1 for production. PowerShell > 7.1 is already for I think over 1 year in preview (so we cannot switch to core because of it being in preview still). As well as some M365 power shell libraries are not compatible yet with PowerShell core. |
Not a VSCode only issue: |
Note that because of the retiring run as accounts this should be the replacement. Downgrading to a earlier version does not seem a very stable mitigation. I also noticed that a brand new Automation account is leveraged with a lower version "out of the box" which is not returned after getting the module through the gallery. |
I am also facing the same issue using Automation Account runbooks with PS version 5. |
I did the install of Powershell 7 and also Downgrade Az modules but now I'm facing a different issue. Somebody could help me please? Bug running a powershell script as Administrator on Powershell 7 Import-Module Modules
|
Just another +1 here, having the same issue with AutomationAccount Runbooks running on a hybrid worker VM. My only option is to use 5.1 and therefore downgrade the module, but this also causes the keyvault module to fail due to version incompatibilities so I've had to downgrade that 2x also. |
What is the latest status of this issue? |
+1 same issue here :(
|
Hi, Facing the same issue. |
We've seen this issue without using Hybrid Workers; pure Azure Automation with Managed Identity (no RunAs usage). |
Using Windows PowerShell is not a workaround. Downgrading to Az.Accounts 2.12.1 and Az.Resources 6.6.0 also fails to resolve. This issue gives more details on the scenarios in which I've reproduced the issue: Everything works in v7, but that's just not a solution when scripting for two major MSFT platforms: Endpoint Manager MDM scripts, and Azure Automation. |
Hi, I'm glad to announce the issue was resolved, please see this comment for more information. For maintenance purpose I'm closing this issue. If you need us to follow up on anything please reply in #21647 . Thanks. |
I am glad you solved the Azure automation issue but I am not sure why you closed this issue. This issue seems to be mostly based around the issue that was not fixed. “And for the conflict with the vscode terminal provided by the PowerShell extension, unfortunately the issue is still there. We couldn't get response from the maintainer of OmniSharp/csharp-language-server-protocol , who we hope can update their dependency of Newtonsoft.Json hence resolve the conflict. I'll update the thread once we get any updates.” |
Hey @mark3grahams , yes, this issue was about vscode originally. But the conversation quickly got mixed by the other issue with Azure Automation. I closed this one purely to avoid confusion and duplication. |
Also getting this issue Az.Accounts version 2.12.5, PS 5.1 windows 10 (VSCode) |
This workaround only helps if you don't want to do fancy serverless things, which I think is what most people want to do nowadays (if there is no on-prem dependency). I've not been using hybrid workers intensively but wonder why people would still stick with Windows PowerShell on it. I'd be curious to learn more should you be willing to share some aspects. For local issues on the workstation, it is just becoming too cumbersome and complicated to fix good old PowerShell 5.1. Microsoft has clearly moved on and doesn't care about PS 5.1 anymore; it is just that they can't remove it as a default on Windows (yet). Sadly, most people are not aware of the complex situation (I've been explaining this to customers quite often within the last few months). VSCode is designed to be used with PowerShell Core. I personally would recommend everybody to leave Windows PowerShell Desktop version behind. I know that for development of code that should still work on PowerShell 5.1, this comes with some challenges to handle the backwards compatibility. I've been able to handle this okay to be honest, and PSScriptAnalyzer can be taught to help with some warnings for backwards compatibility. In Microsoft Land (maybe not limited to that), I do think they embraced developing inside a (Linux) devcontainer as a standard which means that you will need to use PowerShell Core. I personally also wouldn't want to go back to only local development either (or switch to a Windows PC, since I'm using a Mac for decades already). Taking all of this into consideration, you may not expect much from anyone in Microsoft to fix stuff in any area that is still using PowerShell 5.1. Any investment is in PowerShell Core and even though nobody tells you that officially, you may assume that they often simply would like to send a reply like "move to the newest version". They will not do this as an official statement anytime soon for many reasons. That being said, I have decided to stop making own investments (timewise and moneywise) into PowerShell 5.1, too. I know this sounds like an unpopular decision to make, but you must make that sooner or later. ... and all Microsoft SaaS related modules have now been updated in a way so they can be used in PowerShell Core and are multi-platform compatible. This was different like 2 years ago. But the situation has changed for the better in that regard and the journey of PowerShell 5.1 is about to come to a dead end. |
I totally agree with everything you've said here. The serverless aspect makes sense as this wouldn't be applicable. I've been slowly adjusting all our automation to be compatible with PowerShell Core. Right now a lot of our runbooks dot-source other run books. I'm working on turning some of those children runbooks into functions in a module, and making other children runbooks use basic variables over complex ones so we can leverage start-azautomationrunbook. Anything new I've written I make sure is written in a way that can be used with PowerShell Core. One problem is I don't think our 3rd party automation platform has the option of using Core, but with 5.1 EOS coming up in a few years I'm sure that will change as well. Our goal is to use Core for sure. Unfortunately we don't have the resources to make the migration our #1 priority but it is something we are iterating towards. |
So there is the upcomming breaking change:
And this case is still valid for me in VSCode, which still trows the error on Connect-AZAccount when using 3.0.2 of AZ Accounts. |
Was getting the same error for couple of months and finally got time to have a closer look. |
This is not a good solution anymore, as AZ.Accounts will have a breaking change soon. |
Can't agree more - but I'm trying to push here with my contacts at Microsoft and the team behind - stay tuned! |
Any news on this? |
#26206 Related issues |
@michaelmsonne Do you have an update? |
I have pinged the team at Microsoft yesterday again, in my Teams chat I have... |
I also opened my MS connections last week as this is getting more and more a problem in our enterprise environment. (250000 employees, our service completely on azure) |
Update from my contacts: "We will update the issue progress on the GitHub issue tomorrow to facilitate everyone to know the progress". The issue is a bit tricky as I can understand on the team. The team is currently considering how to decouple these tricky issues. Lets see tomorrow! |
The reply is a bit late because the engineers are dealing with some urgent issues. I look forward to @isra-fel giving a progress reply soon. |
I was investigating in the issue with vscode, the one thing that's super suspicious is this error in the fusion log (full version).
The log was captured when Az.Accounts was imported to the integrated terminal. It showed the process of binding My assumption is that the two assemblies in the fusion log are these two from the preloaded modules
pasm: https://gist.github.com/isra-fel/0c503fbccbf301e8c42135dfa47e4408 These are my findings for now. |
@isra-fel hank you for looking deeper into it. Very appreciated that someone now starts to really look into this issue to get it fixed. |
We plan to update every two weeks or monthly, although we may not be able to give an ETA |
Hi @Alex-wdy , Is ther any updates the last month or? This is a very bad bug på deal with all the time :( |
Hey, we really need an update to this! This is not tolerable and keeps us back in everyday work! |
This consistency MS manage with screwing these Az PS modules up is impressive. |
They are never fixing this. The heat death of the universe will come quicker. |
OK so from the author of the PowerShell extension's perspective
I will conclude this issue as below - it's a limitation of PS 5.1 that there's no solution for assembly isolation. The known workarounds are
|
Hi @ITJoeSchmo |
And found another one, I did not fix right now: |
@ITJoeSchmo Thanks for the script, I used it now on my main production machine and it solves my problem with VSCode so far pretty well. Finally I can use VSCode with 5.1 again, although most of the times I use PSCore. |
Description
With the latest version of Az.Accounts version 2.12.3 we face an issue when running the Connect-AzAccount command in PowerShell 5.1.3 terminal in Visual Studio code. The previous version(s) 2.12.2 did not throw an error.
The error occurs with fully installed AZ module latest version 10.0.0.0 or only having the Az.Accounts module installed.
Issue script & Debug output
Environment data
Module versions
Error output
The text was updated successfully, but these errors were encountered: