Issue with Connect-MgGraph in Azure Automation Runbook with Microsoft.Graph.Authentication 2.34.0

Patrick Bus 45 Reputation points
2025-12-31T08:56:31.5733333+00:00

Hello,

I am working on an Azure Automation Runbook using the Microsoft.Graph.Authentication module version 2.34.0, and I encountered an issue when trying to connect using Managed Identity. The script below was working fine in version 2.33.0, but after upgrading, I am seeing an error.

Here’s the code I’m using:

# Connect to Microsoft Graph
try {
    Connect-MgGraph -Identity -NoWelcome
    Write-Output "✅ Connected to Microsoft Graph using Managed Identity"
}
catch {
    Write-Error "❌ Failed to connect to Microsoft Graph: $_"
    throw
}


############################################################
# Disconnect
############################################################

Disconnect-MgGraph
Write-Output "🔌 Disconnected"
Write-Output "✅ Script execution completed successfully"

The error message I receive is:

Failed
The 'Connect-MgGraph' command was found in the module 'Microsoft.Graph.Authentication', but the module could not be loaded. For more information, run 'Import-Module Microsoft.Graph.Authentication'. (Method 'GetTokenAsync' in type 'Microsoft.Graph.PowerShell.Authentication.Core.Utilities.UserProvidedTokenCredential' from assembly 'Microsoft.Graph.Authentication.Core, Version=2.34.0.0' does not have an implementation.

Has anyone else experienced this issue with version 2.34.0? Is there any known solution or workaround? I was able to connect with version 2.33.0 without issues, so I’m wondering if this is a known bug in the latest version.

Any help or guidance would be greatly appreciated!

Thank you in advance!

Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} vote

Answer accepted by question author
  1. Shubham Sharma 7,755 Reputation points Microsoft External Staff Moderator
    2025-12-31T10:51:09.33+00:00

    Hello Patrick Bus

    Thank you for reaching out to Microsoft Q&A.

    Below are the resolution steps: -

    1.) Roll back to v2.33.0

    Microsoft explicitly recommends pinning to a known-good minor version inside Azure Automation.

    Step 1: Remove v2.34.0

    Remove-Module Microsoft.Graph.Authentication -Force

    Step 2: Import v2.33.0 explicitly

    Install``` -Module Microsoft.Graph.Authentication ``

        ``` -RequiredVersion 2.33.0 ``

        ``` -Repository PSGallery ``

        ``` -Force ``

        ``-AllowClobber

    Step 3: Restart the Automation Account worker

    Re-run the job (cold start occurs automatically)

    Connect-MgGraph -Identity will work again.

    2.) Import the full Microsoft.Graph bundle

    In some tenants, importing only Microsoft.Graph.Authentication causes dependency mismatch.

    Install``-Module Microsoft.Graph -RequiredVersion 2.33.0 -Force

    Then in your runbook:

    Import``-Module Microsoft.Graph

    Connect``-MgGraph -Identity -NoWelcome Microsoft docs for your reference: -

    https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/how-to-use-vm-token

    https://learn.microsoft.com/en-us/powershell/microsoftgraph/troubleshooting?view=graph-powershell-1.0

    https://learn.microsoft.com/en-us/azure/automation/shared-resources/modules#specify-a-module-version

    https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/connect-mggraph?view=graph-powershell-1.0

    If the resolution was helpful, do click Accept the Answer and Yes and upvote it 👍 for was this answer helpful, which may help members with similar questions.

    Thank you for helping to improve Microsoft Q&A!

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.