Skip to content
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

Azure Automation Runbook - The type initializer for 'Azure.Core.Pipeline.DiagnosticScopeFactory' threw an exception. #2478

Closed
ibutbul1 opened this issue Dec 5, 2023 · 7 comments

Comments

@ibutbul1
Copy link

ibutbul1 commented Dec 5, 2023

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:

  1. Execute Connect-MgGraph -ClientId $AppIdForGraph -TenantId $TenantId -CertificateThumbprint $CertificateThumbprint.Thumbprint -ErrorAction Stop | Out-Null
  2. 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

@timayabi2020
Copy link
Contributor

@ibutbul1 could you please provide the debug information. i.e. Connect-MgGraph -ClientId $AppIdForGraph -TenantId $TenantId -CertificateThumbprint $CertificateThumbprint.Thumbprint -Debug.

@ibutbul1
Copy link
Author

ibutbul1 commented Dec 7, 2023 via email

@timayabi2020
Copy link
Contributor

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

@mdurini-swisscom
Copy link

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

@ShachafGoldstein
Copy link

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.

@devops-fan
Copy link

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.

pnp/powershell#3637

@timayabi2020
Copy link
Contributor

Hi @ibutbul1 apologies for the late response on this issue. I wasn't able to reproduce the issue using the latest SDK version (2.25.0). See attached images of the successful execution and how my run book looks like.

Image Image

Meanwhile I'll close this since the issue is targeting an old SDK version. Therefore, upgrade to the latest version and open a new issue in case you are still experiencing the same with the new SDK version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants