title: AAD authentication to Azure Windows Server 2019 virtual machine
body: <p>I'm having issues authenticating my Azure Windows Server 2019 virtual machine with my AAD user.</p>
  
  <p>According to Microsoft's documentation: <a href="https://docs.microsoft.com/en-us/azure/active-directory/devices/howto-vm-sign-in-azure-ad-windows" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/active-directory/devices/howto-vm-sign-in-azure-ad-windows</a>, I've created Azure Windows Server 2019 VM using Terraform and installed Windows AAD authentication extension using:</p>
  
  <pre><code>  provisioner "local-exec" {
      command = "az vm extension set --publisher Microsoft.Azure.ActiveDirectory --name AADLoginForWindows --resource-group ${data.azurerm_resource_group.RG.name} --vm-name ${var.prefix}"
    }
  </code></pre>
  
  <p>The machine is up and running and the extension installed successfully.
  <a href="https://i.stack.imgur.com/WmDwv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WmDwv.png" alt="enter image description here"></a></p>
  
  <p>I've also assigned the appropriate role with users and groups in order to log in that VM with AAD authentication.
  <a href="https://i.stack.imgur.com/XpzeC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XpzeC.png" alt="enter image description here"></a></p>
  
  <p>And ensured that my VMs network configuration permits outbound access over TCP port 443.</p>
  
  <p>However, when trying to log in the VM with RDP and my AAD user (associated with the role) I get the error "The logon attempt failed" as shown above.</p>
  
  <p><a href="https://i.stack.imgur.com/QOUMC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QOUMC.png" alt="enter image description here"></a></p>
  
  <p>I'm trying to RDP Windows 10 VM from Windows 10 Pro VM.
  <a href="https://i.stack.imgur.com/gQuib.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gQuib.png" alt="enter image description here"></a></p>
  
  <p>My Windows 10 Pro VM is joined to Azure AD (with my AAD user). 
  <a href="https://i.stack.imgur.com/Zhta5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zhta5.png" alt="enter image description here"></a></p>
  
  <p>Yet, I get this error when RDP to the other Windows VM from my main Win10Pro VM.
  When trying to login Linux VMs with AAD authentication everything works as expected.</p>
  
  <p>Running the command "dsregcmd /status" from the Win10Pro VM gave the above output:
  <a href="https://i.stack.imgur.com/yw3nz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yw3nz.png" alt="enter image description here"></a></p>
  
  <p>Also tried to RDP with "AzureAD\Username@Domain" but git the same credentials error.</p>
  
  <p>What can be the problem?
  Thanks for the help :)</p>