Share via

Errors when AADLoginForWindows extension is enabled on the VM

Garcia, Cha 40 Reputation points
2026-03-09T23:10:38.3133333+00:00

I’m attempting to enable Microsoft Entra ID authentication for a Windows VM that I access through Azure Bastion.

User's image

However, when I try to enable the AADLoginForWindows extension, the deployment fails and I receive the following error:

The handler for VM extension type 'Microsoft.Azure.ActiveDirectory.AADLoginForWindows' has reported terminal failure for VM extension 'AADLogin' with error message: 'Install failed for plugin (name: Microsoft.Azure.ActiveDirectory.AADLoginForWindows, version 1.3.0.0) with exception Command C:\\Packages\\Plugins\\Microsoft.Azure.ActiveDirectory.AADLoginForWindows\\1.3.0.0\\AADLoginForWindowsHandler.exe of Microsoft.Azure.ActiveDirectory.AADLoginForWindows has exited with Exit code: 50. Error: '.\r\n    \r\n'Install handler failed for the extension. More information on troubleshooting is available at https://aka.ms/vmextensionwindowstroubleshoot'"


So far, I have:

Checked that the Microsoft Entra ID tenant is properly configured.

  • Confirmed the required RBAC roles are assigned.
    • Virtual Machine Administrator Login for admin privileges
    • Virtual Machine User Login for end users

Despite this, the extension installation continues to fail.

Has anyone encountered this issue before or can provide guidance on:

Common causes for AADLoginForWindows extension failures?

Required networking endpoints or firewall configurations?

Additional prerequisites that may be missing?

Any assistance would be greatly appreciated.

Azure Virtual Machines
Azure Virtual Machines

An Azure service that is used to provision Windows and Linux virtual machines.

0 comments No comments

Answer accepted by question author
  1. Jilakara Hemalatha 11,785 Reputation points Microsoft External Staff Moderator
    2026-03-09T23:52:03.1166667+00:00

    Hello Garcia, Cha,

    Thank you for sharing the details regarding the AADLoginForWindows extension deployment failure on your VM. Based on the error message and information provided, the issue appears to be related to prerequisites or connectivity required for enabling Microsoft Entra ID authentication on Windows VMs.

    Below are the most common causes and recommended steps to resolve the issue:

    1. Check OS Compatibility

    The AADLoginForWindows extension supports the following Windows versions:

    • Windows Server 2022 or later

    Windows 10 / 11 (22H2 or later)

    If your VM is running an unsupported OS version, the extension will fail with Exit code 50.

    Reference: https://learn.microsoft.com/en-us/entra/identity/devices/howto-vm-sign-in-azure-ad-windows#prerequisites
    2. Enable System Assigned Managed Identity

    The extension requires a system-assigned managed identity on the VM. Without it, the extension cannot retrieve tenant information from Azure Instance Metadata Service.

    Reference: https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/how-to-configure-managed-identities?pivots=qs-configure-portal-windows-vm

    3.Validate Network and Firewall Configuration

    The VM must have outbound HTTPS access to the following Microsoft identity endpoints:

    • https://login.microsoftonline.com
    • https://enterpriseregistration.windows.net
    • https://device.login.microsoftonline.com
    • https://pas.windows.net
    • Ensure NSGs, firewalls, or corporate proxies allow outbound HTTPS (443) traffic to these endpoints.
    • Confirm DNS resolution works correctly.

    Reference: Troubleshooting Azure Windows VM extension failures

    Troubleshoot AADLoginForWindows deployment

    Once the above prerequisites are verified, reinstall the extension and let us know the outcome. This will help us further investigate if the issue persists.


1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2026-03-09T23:11:02.6333333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Exit code 50 for the AADLoginForWindows extension indicates that the extension cannot complete the Microsoft Entra join on the VM. Use the built‑in troubleshooting flow for the AADLoginForWindows extension and the VM’s device join state.

    1. On the VM, check the extension logs
      • Connect with local admin credentials (for example via Bastion local account).
      • Open C:\WindowsAzure\Logs\Plugins\Microsoft.Azure.ActiveDirectory.AADLoginForWindows\1.0.0.1.
      • Review CommandExecution.log or CommandExecution_YYYYMMDDHHMMSSSSS.log for the detailed error that caused exit code 50.
    2. Verify Azure Instance Metadata Service (AIMS) responses
      • In an elevated PowerShell window on the VM run:
        • curl.exe -H Metadata:true "http://169.254.169.254/metadata/instance?api-version=2017-08-01"
          • Must return correct information about the VM.
        • curl.exe -H Metadata:true "http://169.254.169.254/metadata/identity/info?api-version=2018-02-01"
          • Must return a valid tenant ID for the subscription.
        • curl.exe -H Metadata:true "http://169.254.169.254/metadata/identity/oauth2/token?resource=urn:ms-drs:enterpriseregistration.windows.net&api-version=2018-02-01"
          • Must return a valid access token from Microsoft Entra ID.
      • If these calls fail or the tenant ID is missing, ensure the VM has a system‑assigned managed identity enabled on the Identity blade and that networking allows access to the metadata IP 169.254.169.254.
    3. Confirm required outbound endpoints and DNS resolution
      • From the VM, run in PowerShell:
        • curl.exe https://login.microsoftonline.com/ -D -
        • curl.exe https://login.microsoftonline.com/<TenantID>/ -D -
        • curl.exe https://enterpriseregistration.windows.net/ -D -
        • curl.exe https://device.login.microsoftonline.com/ -D -
        • curl.exe https://pas.windows.net/ -D -
      • login.microsoftonline.com/<TenantID>, enterpriseregistration.windows.net, and pas.windows.net may legitimately return 404 Not Found; this still proves reachability.
      • If any command fails with “Couldn't resolve host”, check DNS with:
        • nslookup <URL>
        • If that fails, try a public resolver: nslookup <URL> 208.67.222.222 and adjust the DNS server on the VM’s VNet/subnet/NSG as needed.
      • If outbound Internet is restricted, ensure these endpoints (or the appropriate service tags, such as AzureActiveDirectory plus any required public discovery IPs) are allowed through firewalls/NSGs.
    4. Validate device join state
      • Run dsregcmd /status on the VM.
      • For a successful configuration, Device State should show AzureAdJoined : YES.
      • If not joined, use the errors in User Device Registration\Admin log in Event Viewer (Applications and Services Logs\Microsoft\Windows\User Device Registration\Admin) together with the extension logs to identify what is blocking the join (for example, tenant discovery, connectivity to enterpriseregistration.windows.net, or duplicate device name).
    5. Check for common terminal error patterns
      • If the extension logs show:
        • DSREG_E_MSI_TENANTID_UNAVAILABLE (terminal error code 1007, exit code -2145648574): the extension cannot obtain the tenant ID from AIMS. Confirm the managed identity is enabled and that curl .../metadata/identity/info returns a tenant ID.
        • DSREG_AUTOJOIN_DISC_FAILED (exit code -2145648607): the extension cannot reach https://enterpriseregistration.windows.net. Re‑check outbound access and DNS to that endpoint as in step 3.
      • If the logs show exit code 51 (“This extension isn't supported on this operating system”), the OS is unsupported; AADLoginForWindows is only for Windows Server 2022 or later. In that case, uninstall the extension or upgrade the OS.
    6. After fixing connectivity/identity issues
      • Once AIMS responses, DNS, outbound endpoints, and OS support are confirmed, re‑run the extension deployment.
      • Then re‑check dsregcmd /status to confirm AzureAdJoined : YES before using Bastion with Microsoft Entra sign‑in.

    These steps address the common causes of AADLoginForWindows extension failures: missing managed identity/tenant information, blocked outbound endpoints or DNS, unsupported OS, and device join errors.


    References:

    1 person found this answer 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.