Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.26k stars 3.87k forks source link

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

Open mrvdsah opened 1 year ago

mrvdsah commented 1 year ago

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

Connect-AzAccount : Method 'get_SerializationSettings' in type 'Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient' from assembly 'Microsoft.Azure.PowerShell.Clients.Reso
urceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
At line:1 char:1
+ Connect-AzAccount
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-AzAccount], TypeLoadException
    + FullyQualifiedErrorId : System.TypeLoadException,Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

Environment data

Name                           Value
----                           -----
PSVersion                      5.1.17763.3770
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.3770
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Module versions

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.12.3     Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault...}

Error output

Resolve-AzError : Method 'get_SerializationSettings' in type 'Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient' from assembly 'Microsoft.Azure.PowerShell.Clients.ResourceManager, Version=1.0.0.0, 
Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
At line:1 char:1
+ Resolve-AzError
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Resolve-AzError], TypeLoadException
    + FullyQualifiedErrorId : System.TypeLoadException,Microsoft.Azure.Commands.Profile.Errors.ResolveError
BartDecker commented 1 year ago

Can confirm. Have the same problem.

Poolshark314 commented 1 year ago

Same here

flizzer commented 1 year ago

Ditto...

jdarre commented 1 year ago

Same here. It fails i Terminal as well Name Value


PSVersion 5.1.22621.963 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.22621.963 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

isra-fel commented 1 year ago

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:

Symptom

The 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 cause

The 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

Solution

We 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.

axdko commented 1 year ago

Workarounds

  • Use PowerShell 7 instead of Windows PowerShell 5.1.

    • Install PowerShell 7
    • Go to the command palette of VS Code (F1 or Ctrl + Shift + P), select: "PowerShell: Show Session Menu" and then select: "Switch to: PowerShell (x64)"

Is it possible that it doesn't work in PS7 ?

Name Value
PSVersion 7.3.4
PSEdition Core
GitCommitId 7.3.4
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

I had to downgrade the two mentioned Az modules (Az.Accounts v2.12.1, Az.Resources v6.6.0) to make it work.

mrvdsah commented 1 year ago

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.

ElSrJuez commented 1 year ago

Not a VSCode only issue: Also happens with Azure Automation runbook on Hybrid Worker (WS2K22), latest Az Module installed.

rbeltman commented 1 year ago

Not a VSCode only issue: Also happens with Azure Automation runbook on Hybrid Worker (WS2K22), latest Az Module installed.

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.

alvindutt commented 1 year ago

I am also facing the same issue using Automation Account runbooks with PS version 5.

danilomsousa commented 1 year ago

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 Connect-AzAccount: C:\Nebula\Configuration\Scripts\Meridian\ImportSSLCertificate.ps1:21 Line | 21 | Connect-AzAccount -ServicePrincipal -Tenant $BootstrapConfig.AzureTen … | ~~~~~~~~~~~~~~~~~ | The 'Connect-AzAccount' command was found in the module 'Az.Accounts', but the module could not be loaded due to | the following error: [Assembly with same name is already loaded] For more information, run 'Import-Module | Az.Accounts'.

Import-Module PS C:\Nebula\Configuration\Scripts> Import-Module Az.Accounts Import-Module: Assembly with same name is already loaded

Modules

PS C:\Nebula\Configuration\Scripts> Get-Module -listavailable
    Directory: C:\Users\default.vm\Documents\PowerShell\Modules
ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     2.12.1                Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzCo…
Script     5.7.1                 Az.Compute                          Core,Desk {Remove-AzAvailabilitySet, Get-AzAvaila…
Script     4.9.2                 Az.KeyVault                         Core,Desk {Add-AzKeyVaultCertificate, Update-AzKe…
Script     6.6.0                 Az.Resources                        Core,Desk {Get-AzProviderOperation, Remove-AzRole…
Script     4.6.0                 Az.Sql                              Core,Desk {Invoke-AzSqlServerExternalGovernanceSt…
Script     5.6.0                 Az.Storage                          Core,Desk {Get-AzStorageAccount, Get-AzStorageAcc…
    Directory: C:\program files\powershell\7\Modules
ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Manifest   7.0.0.0               CimCmdlets                          Core      {Get-CimAssociatedInstance, Get-CimClas…
Manifest   1.2.5                 Microsoft.PowerShell.Archive        Desk      {Compress-Archive, Expand-Archive}
Manifest   7.0.0.0               Microsoft.PowerShell.Diagnostics    Core      {Get-WinEvent, New-WinEvent, Get-Counte…
Manifest   7.0.0.0               Microsoft.PowerShell.Host           Core      {Start-Transcript, Stop-Transcript}
Manifest   7.0.0.0               Microsoft.PowerShell.Management     Core      {Add-Content, Clear-Content, Get-Clipbo…
Manifest   7.0.0.0               Microsoft.PowerShell.Security       Core      {Get-Acl, Set-Acl, Get-PfxCertificate, …
Manifest   7.0.0.0               Microsoft.PowerShell.Utility        Core      {Export-Alias, Get-Alias, Import-Alias,…
Manifest   7.0.0.0               Microsoft.WSMan.Management          Core      {Disable-WSManCredSSP, Enable-WSManCred…
Script     1.4.8.1               PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Script     2.2.5                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-M…
Script     7.0.0.0               PSDiagnostics                       Core      {Disable-PSTrace, Disable-PSWSManCombin…
Script     2.2.6                 PSReadLine                          Desk      {Get-PSReadLineKeyHandler, Set-PSReadLi…
Binary     2.0.3                 ThreadJob                           Desk      Start-ThreadJob
    Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.0.1                 Microsoft.PowerShell.Operation.Val… Desk      {Get-OperationValidation, Invoke-Operat…
Binary     1.0.0.1               PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Script     3.4.0                 Pester                              Desk      {Describe, Context, It, Should…}
Script     1.0.0.1               PowerShellGet                       Desk      {Install-Module, Find-Module, Save-Modu…
Script     1.2                   PSReadline                          Desk      {Get-PSReadlineKeyHandler, Set-PSReadli…
    Directory: C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell
ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     1.0.0.0               Microsoft.MonitoringAgent.PowerShe… Desk
    Directory: C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.1722.0
ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     1.0                   HybridRegistration                  Desk
    Directory: C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.1722.0\HybridAgent\Modules
ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     1.0                   Orchestrator.AssetManagement.Cmdle… Desk      {Get-AutomationVariable, Set-Automation…
insomniacc commented 1 year ago

Just another +1 here, having the same issue with AutomationAccount Runbooks running on a hybrid worker VM. Seems there's some issues with PS Core in runbooks and which are still in preview so I'm limited to running 5.1.

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.

mrvdsah commented 1 year ago

What is the latest status of this issue?

marcoflorian commented 1 year ago

+1 same issue here :(

Install-Module -Name MSOnline
Install-Module -Name Az.Resources
Install-Module -Name Az.Accounts

connect-msolservice 
Connect-AzAccount

PS C:\Windows\system32> Connect-AzAccount
Connect-AzAccount : Method 'get_SerializationSettings' in type 'Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient' from assembly
'Microsoft.Azure.PowerShell.Clients.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
At line:1 char:1
+ Connect-AzAccount
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-AzAccount], TypeLoadException
    + FullyQualifiedErrorId : System.TypeLoadException,Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand
pmoisontech commented 1 year ago

Hi,

Facing the same issue. Spent several hours to try to have a stable dev env with Az PS in VS Code. Any update about a fix?

StevieLamb commented 1 year ago

Not a VSCode only issue: Also happens with Azure Automation runbook on Hybrid Worker (WS2K22), latest Az Module installed.

We've seen this issue without using Hybrid Workers; pure Azure Automation with Managed Identity (no RunAs usage).

StevieLamb commented 1 year ago

Using Windows PowerShell is not a workaround. I and a team member have reliably reproduced this issue via that mechanism.

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: https://github.com/Azure/azure-powershell/issues/9728#issuecomment-1625902173

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. That runtime cannot be targeted by Intune, and is not in production in AA.

isra-fel commented 1 year ago

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 https://github.com/Azure/azure-powershell/issues/21647 . Thanks.

mark3grahams commented 1 year ago

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.”

isra-fel commented 1 year ago

This issue seems to be mostly based around the issue that was not fixed.

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.

KeysAU commented 1 year ago

Also getting this issue Az.Accounts version 2.12.5, PS 5.1 windows 10 (VSCode)

ziesemer commented 1 year ago

This issue seems to be mostly based around the issue that was not fixed.

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.

21647 is specific to working with Azure Automation. This ticket was originally opened specific to the need for support within VSC. @isra-fel - please re-open this ticket so that it can be used to track this issue through to completion only after this is appropriately again working within VS Code.

superfliege commented 1 year ago

Same problem here. :( had to downgrade @isra-fel please reopen issue, because it is not azure automation related. it is vscode related.

SkitariiAuxiliary commented 1 year ago

Any update on an actually resolution of this issue? It's getting really annoying juggling multiple versions.

yevheniilavrenchuk commented 1 year ago

What worked for me, was to downgrade Az.Accounts module to 2.12.1 Get currently installed version: Get-Module Az.Accounts -ListAvailable Uninstall it: Uninstall-Module Az.Accounts -RequiredVersion <your-version> Install downgraded one: Install-Module Az.Accounts -RequiredVersion 2.12.1

Reinhard-S commented 1 year ago

I got the same exception when trying to fetch secrets from a key vault using Get-AzureKeyVaultSecret.
As I didn't want to use a specific, older, version of Az.Accounts, I investigated further and found that Enable-AzureRmAlias solved the issue for me:

Remove-Module AzureRM.Profile -Force -ErrorAction SilentlyContinue  # AzureRM causes a conflict with Az modules

if (!(Get-Module -ListAvailable -Name Az.Accounts)) {
  Install-Module -Name Az.Accounts -Repository PSGallery -AllowClobber -Force -Scope CurrentUser  
} 
if (!(Get-Module -ListAvailable -Name Az.KeyVault)) {
  Install-Module -Name Az.KeyVault -Repository PSGallery -AllowClobber -Force -Scope CurrentUser 
} 

Import-Module Az.Accounts
Import-Module Az.KeyVault

Enable-AzureRmAlias -Scope CurrentUser -ErrorAction SilentlyContinue  # solves type implementation exception
StevieLamb commented 1 year ago

Those with a custom profile should beware the command

Enable-AzureRmAlias -Scope CurrentUser -ErrorAction SilentlyContinue # solves type implementation exception

Attempting this a year ago had no impact on the problem, but did break my profile. So your mileage will vary

Ramadel commented 1 year ago

I have a brand new set up and I'm getting these exact same problems as OP. Any updates on this major issue?

btfromcc commented 1 year ago

Same problem here.

mundayn commented 1 year ago

Same issue here with VSCode and Automation Account.

Fix is to:

Uninstall-Module Az.Accounts -RequiredVersion 2.13.1 Install-Module Az.Accounts -RequiredVersion 2.12.1 -Force

and Az.Resources to 6.6.0

EDIT! does not fix it, now I can't run 'Get-AzRouteTable' as it requires 'Az.Accounts' Version 2.13.0 and above. What a headache.

System.Management.Automation.CommandNotFoundException: The 'Get-AzRouteTable' command was found in the module 'Az.Network', but the module could not be loaded. For more information, run 'Import-Module Az.Network'.

This module requires Az.Accounts version 2.13.0. An earlier version of Az.Accounts is imported in the current PowerShell session. Please open a new session before importing this module. This error could indicate that multiple incompatible versions of the Azure PowerShell cmdlets are installed on your system. Please see https://aka.ms/azps-version-error for troubleshooting information. The module to process 'Az.Network.psm1', listed in field 'ModuleToProcess/RootModule' of module manifest 'C:\Program Files\WindowsPowerShell\Modules\Az.Network\6.2.0\Az.Network.psd1' was not processed because no valid module was found in any module directory.

brolifen commented 1 year ago

Same error here running Hybrid runbook and version 2.13.1 everything is broken. Microsoft fix this how is this a production release!

IIIdefconIII commented 1 year ago

still screwed not working even downgrading doesnt work and getting other errors

Reinhard-S commented 1 year ago

Hello @isra-fel,

as this issue is still not solved and there's much additional feedback after the issue was closed, could you please provide an update to the community if and how this problem is being addressed by Microsoft?

Here are my thoughts on the mentioned workarounds:

Thank you & best Regards, Reinhard

IIIdefconIII commented 1 year ago

Upgrade tot ps 7. ISE is still on version 5.2, I still cannot delete the azure tenant to my account

Van: Reinhard-S @.> Verzonden: maandag 9 oktober 2023 11:01 Aan: Azure/azure-powershell @.> CC: Thomas van Dalen @.>; Comment @.> Onderwerp: Re: [Azure/azure-powershell] 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 (Issue #21960)

Hello @isra-felhttps://github.com/isra-fel,

as this issue is still not solved and there's much additional feedback after the issue was closed, could you please provide an update to the community if and how this problem is being addressed by Microsoft?

Here are my thoughts on the mentioned workarounds:

Thank you & best Regards, Reinhard

— Reply to this email directly, view it on GitHubhttps://github.com/Azure/azure-powershell/issues/21960#issuecomment-1752599330, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACLVJWYML4RMCYG6DF6C2UTX6O4NVAVCNFSM6AAAAAAYVF7UBGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJSGU4TSMZTGA. You are receiving this because you commented.Message ID: @.***>

lesca commented 1 year ago

Still not resolved on 10.4.1 September release: https://github.com/Azure/azure-powershell/releases/tag/v10.4.1-September2023 Environment: VS Code - PowerShell Extension - run Connect-AzAccount

Message:

Connect-AzAccount : Method 'get_SerializationSettings' in type 'Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient' from assembly 
'Microsoft.Azure.PowerShell.Clients.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.    

As the workaround, install the May release: https://github.com/Azure/azure-powershell/releases/tag/v9.7.1-May2023

bahadir-be commented 1 year ago

Not Solved yet???

IIIdefconIII commented 1 year ago

Nope had to contact MS 2nd lineaire support to get rid of an tenant

Met vriendelijke groet,


Thomas van Dalen

E: @.**@.>

T: +316 30 929 009


From: BAHADIR @.> Sent: Tuesday, November 7, 2023 11:28:15 AM To: Azure/azure-powershell @.> Cc: Thomas van Dalen @.>; Comment @.> Subject: Re: [Azure/azure-powershell] 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 (Issue #21960)

Not Solved yet???

— Reply to this email directly, view it on GitHubhttps://github.com/Azure/azure-powershell/issues/21960#issuecomment-1798229096, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACLVJW4SKQGXB7VAOFSH3KDYDIEL7AVCNFSM6AAAAAAYVF7UBGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJYGIZDSMBZGY. You are receiving this because you commented.Message ID: @.***>

scuba6388 commented 1 year ago

Bump, having similar issues

IIIdefconIII commented 1 year ago

Bump, having similar issues

After creating a support ticket @ MS, i gently asked them to escalaet the question to second/third line support or the dev department. Within a total of 2 weeks, which is kinda ok for me, they removed it from their site manually which is great!

mark3grahams commented 1 year ago

@isra-fel Could you respond?

NHEY23 commented 1 year ago

Got it sorted.

I deleted all az modules from the modules folder installed Az modules version 9.6 using the requiredversion switch

This installs the correct version of everything except Az.accounts which is the latest version.

I then installed version 2.12.1 of Az.accounts using the requiredversion switch and then deleted version 2.13.2 from disk.

all my runbooks are working now.

mark3grahams commented 1 year ago

I think that's been the fix for the last eight months. Or is there something new that I am missing?

NHEY23 commented 1 year ago

no, comments even from last week other people having the issue. I updated to the latest version of Az modules a few days ago and it broke all my runbooks that ran on the hybrid worker, and then I found this GitHub issue.

Thought other people might find my solution helpful as all the existing ones didn't work for me.

mark3grahams commented 1 year ago

Yeah, always good to share. I was hoping for something new.

The lack of resolution or comment on this issue is a joke.

mrvdsah commented 11 months ago

Hello @isra-fel, this issue is still not fixed and we still need to apply a workaround by downgrading Az modules. Which is not a long-term solution.

Can you please remove the closed tag as the issue is not fixed.

IIIdefconIII commented 11 months ago

Hello @isra-fel, this issue is still not fixed and we still need to apply a workaround by downgrading Az modules. Which is not a long-term solution.

Can you please remove the closed tag as the issue is not fixed.

Indeed strange we as end users etc need to do alot if work arounds to get this work proper

isra-fel commented 11 months ago

Reopening the issue for new activity. @mrvdsah @IIIdefconIII do you mean the issue with automation runbook or vscode?

darrens280 commented 11 months ago

Hi

Still an issue today via Azure Automation runbook using Hybrid Worker VM (Runtime version 5.1) with latest PowerShell Az module (installed fresh using PSGallery method as per MS documentation):

Connect-AzAccount cmdlet breaks with: _Method 'getSerializationSettings' in type 'Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient' from assembly 'Microsoft.Azure.PowerShell.Clients.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bxxxxxxx35' does not have an implementation.

Following downgrade of Az.Accounts to 2.12.1, and Az.Resources to 6.6.0, the Connect-AzAccount command then works, but the runbook then fails on the Get-AzStorageAccountKey command due to dependencies. Tried downgrading Az.Storage module as well to no avail (tried 5.6.0, 5.7.0, 5.8.0).

Also tried rolling back ALL the Az modules to v11.0, also, v10.0, and v9.7 as suggested above, but every combination results in missing dependencies

ModuleType Version    Name                                ExportedCommands                                              
---------- -------    ----                                ----------------                                              
Script     2.13.2     Az.Accounts                         {Disable-AzDataCollection, Disable-AzContextAutosave, Enabl...
Script     6.12.1     Az.Resources                        {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzRo...
Script     6.0.1      Az.Storage                          {Get-AzStorageAccount, Get-AzStorageAccountKey, New-AzStora...
Binary     2.0.2.182  AzureAD                             {Add-AzureADApplicationOwner, Get-AzureADApplication, Get-A...

Hybrid Worker VM has a System Managed Identity, which has been assigned relevant permissions on the target Storage Account.

Thanks Darren

KeysAU commented 11 months ago

This issue, which has been present since May, is still unresolved. Managing the various versions and installations continues to be a challenging task.

IIIdefconIII commented 11 months ago

I escalted to support and they fixed my issues manually

Met vriendelijke groet,


Thomas van Dalen

E: @.**@.>

T: +316 30 929 009


From: Keith Waterman @.> Sent: Monday, December 18, 2023 3:36:56 AM To: Azure/azure-powershell @.> Cc: Thomas van Dalen @.>; Mention @.> Subject: Re: [Azure/azure-powershell] 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 (Issue #21960)

This issue, which has been present since May, is still unresolved. Managing the various versions and installations continues to be a challenging task.

— Reply to this email directly, view it on GitHubhttps://github.com/Azure/azure-powershell/issues/21960#issuecomment-1859451642, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACLVJWZVKDAB4VDUO5OQ2ITYJ6T4RAVCNFSM6AAAAAAYVF7UBGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJZGQ2TCNRUGI. You are receiving this because you were mentioned.Message ID: @.***>