msgraph-sdk-powershell
msgraph-sdk-powershell copied to clipboard
Azure Automation Runbook - The type initializer for 'Azure.Core.Pipeline.DiagnosticScopeFactory' threw an exception.
Describe the bug
Since the update of the Microsoft.Graph.Authentication on my Azure Automation account to the version 2.10, I'm unable to authenticate on with my App Registration when it's running on Azure.
To Reproduce Steps to reproduce the behavior:
- Execute Connect-MgGraph -ClientId $AppIdForGraph -TenantId $TenantId -CertificateThumbprint $CertificateThumbprint.Thumbprint -ErrorAction Stop | Out-Null
- See error at
The type initializer for 'Azure.Core.Pipeline.DiagnosticScopeFactory' threw an exception.
Expected behavior
Successfully authenticate to the Graph API as it does so on the Hybrid Worker.
Module Version Hybrid Worker - 1.27.0 Azure Automation Account - 2.10
Environment Data
5.1
@ibutbul1 could you please provide the debug information. i.e. Connect-MgGraph -ClientId $AppIdForGraph -TenantId $TenantId -CertificateThumbprint $CertificateThumbprint.Thumbprint -Debug.
Connect-MgGraph : A command that prompts the user failed because the host program or the command type does not support user interaction. The host was attempting to request confirmation with the following message: The type initializer for 'Azure.Core.Pipeline.DiagnosticScopeFactory' threw an exception.
From: Tim @.> Sent: Tuesday, December 5, 2023 17:27 To: microsoftgraph/msgraph-sdk-powershell @.> Cc: Itzhak Butbul @.>; Mention @.> Subject: [!EXTERNAL!] Re: [microsoftgraph/msgraph-sdk-powershell] Azure Automation Runbook - The type initializer for 'Azure.Core.Pipeline.DiagnosticScopeFactory' threw an exception. (Issue #2478)
@ibutbul1https://github.com/ibutbul1 could you please provide the debug information. i.e. Connect-MgGraph -ClientId $AppIdForGraph -TenantId $TenantId -CertificateThumbprint $CertificateThumbprint.Thumbprint -Debug.
— Reply to this email directly, view it on GitHubhttps://github.com/microsoftgraph/msgraph-sdk-powershell/issues/2478#issuecomment-1841019387, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AYDL3HMCPUNEN2IEXUSYMVTYH44MRAVCNFSM6AAAAABAHTY3RWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBRGAYTSMZYG4. You are receiving this because you were mentioned.Message ID: @.***>
The information contained in this email, including any attachments, may be privileged, confidential or protected by intellectual property rights, and is for the intended recipient only. If you have received this email in error, please notify the sender immediately and remove it from your system.
@ibutbul1 I was asking if it's possible to add -Debug parameter so that we can be able to see the verbose information concerning the error.
@timayabi2020 it's happening to me the same on my local machine: even adding the debug parameter, the error is the same, no extra details....I also tried to downgrade to 2.9.1, no effects.
https://stackoverflow.com/questions/78029415/connect-mggraph-cmdlet-throws-different-errors-in-powershell-5-1-and-7-4
solved it for me, doing Disconnect-PnPOnline before the connect-mggraph.
I had this error come up with in my script, where both PnP.Powershell and MS Graph API modules are being called. Unfortunately the fix of "Disconnect-PnPOnline" did not work for me. But the workaround fix created by @TobiasAT on PnP Bug #3637 (linked below) resolved the problem for me.
https://github.com/pnp/powershell/issues/3637