azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Issue authenticating using Connect-AzAccount

Open dmarquez1991 opened this issue 1 year ago • 3 comments

Description

Trying to authenticate to tenant using ConnectAzAccount but no avail please see script pasted in output section

Script or Debug output

Connect-AzAccount
Please select the account you want to login with.

WARNING: Unable to acquire token for tenant 'organizations' with error 'InteractiveBrowserCredential authentication
failed: User canceled authentication. '
WARNING: Please run 'Connect-AzAccount -DeviceCode' if browser is not supported in this session.
Connect-AzAccount : InteractiveBrowserCredential authentication failed: User canceled authentication.
At line:1 char:1
+ Connect-AzAccount
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Connect-AzAccount], AuthenticationFailedException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

PS C:\Windows\system32> 'Connect-AzAccount -DeviceCode'
Connect-AzAccount -DeviceCode
PS C:\Windows\system32> Connect-AzAccount -DeviceCode
Please select the account you want to login with.

[Login to Azure] To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code FSL5WSCRF to authenticate.
Retrieving subscriptions for the selection...
WARNING: Unable to acquire token for tenant 'b70ad5aa-a3dc-4466-b82f-cc1fd8bdb5b6' with error 'Authentication failed against tenant b70ad5aa-a3dc-4466-b82f-cc1fd8bdb5b6. User interaction is required. This may be due to the conditional access policy settings such as
multi-factor authentication (MFA). If you need to access subscriptions in that tenant, please rerun 'Connect-AzAccount' with additional parameter '-TenantId b70ad5aa-a3dc-4466-b82f-cc1fd8bdb5b6'.'

[Announcements]
With the new Azure PowerShell login experience, you can select the subscription you want to use more easily. Learn more about it and its configuration at https://go.microsoft.com/fwlink/?linkid=2271909.

If you encounter any problem, please open an issue at: https://aka.ms/azpsissue

Subscription name Tenant
----------------- ------
Microsoft Azure   b70ad5aa-a3dc-4466-b82f-cc1fd8bdb5b6

Environment data

No response

Module versions

No response

Error output

Connect-AzAccount
Please select the account you want to login with.

WARNING: Unable to acquire token for tenant 'organizations' with error 'InteractiveBrowserCredential authentication
failed: User canceled authentication. '
WARNING: Please run 'Connect-AzAccount -DeviceCode' if browser is not supported in this session.
Connect-AzAccount : InteractiveBrowserCredential authentication failed: User canceled authentication.
At line:1 char:1
+ Connect-AzAccount
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Connect-AzAccount], AuthenticationFailedException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

PS C:\Windows\system32> 'Connect-AzAccount -DeviceCode'
Connect-AzAccount -DeviceCode
PS C:\Windows\system32> Connect-AzAccount -DeviceCode
Please select the account you want to login with.

[Login to Azure] To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code FSL5WSCRF to authenticate.
Retrieving subscriptions for the selection...
WARNING: Unable to acquire token for tenant 'b70ad5aa-a3dc-4466-b82f-cc1fd8bdb5b6' with error 'Authentication failed against tenant b70ad5aa-a3dc-4466-b82f-cc1fd8bdb5b6. User interaction is required. This may be due to the conditional access policy settings such as
multi-factor authentication (MFA). If you need to access subscriptions in that tenant, please rerun 'Connect-AzAccount' with additional parameter '-TenantId b70ad5aa-a3dc-4466-b82f-cc1fd8bdb5b6'.'

[Announcements]
With the new Azure PowerShell login experience, you can select the subscription you want to use more easily. Learn more about it and its configuration at https://go.microsoft.com/fwlink/?linkid=2271909.

If you encounter any problem, please open an issue at: https://aka.ms/azpsissue

Subscription name Tenant
----------------- ------
Microsoft Azure   b70ad5aa-a3dc-4466-b82f-cc1fd8bdb5b6

dmarquez1991 avatar Jun 07 '24 18:06 dmarquez1991

Same problem here. AuthN popup sometimes appears briefly and then vanishes. Az Module v12.0.0 on W11 build 22631.3593 with PowerShell 7.4.2

image

hooverken avatar Jun 07 '24 20:06 hooverken

i get the same thing in win10 with az.accounts 3.0.0. sometimes it will crash the window. i do not get this in win2016 or win2019.

Technomancer-SysAdmin avatar Jun 11 '24 20:06 Technomancer-SysAdmin

I'm the same, just hangs right here (actually stayed there and didn't even fail (had to CTRL+C)) overnight: image When I do it with -DeviceCode, that actually works. Also when I Connect-AzAccount -Identity from Azure Automation runbook (PowerShell 7.2 runtime environment and System-Assigned Managed Identity), it works there too. Windows PowerShell 5.1 in Azure Automation seems to be disaster with the Az and AzureRM conflict. The entirety of the many different Azure modules is pretty intimidating and very difficult.

JeremyTBradshaw avatar Jun 12 '24 12:06 JeremyTBradshaw

Same issue here with a recently reimaged computer and PowerShell 7.4.3.

In the past, this would pop up the account selection dialog in the browser, but now I get nothing at all. I don't know how to specify the account to log in with since this always just prompted to select one.

traberc avatar Jul 18 '24 21:07 traberc

Sounds dumb, but make sure to minimize all windows and then don't maximize just this one window. You might see a special login window pop-up behind. This was my issue 👴🤓

JeremyTBradshaw avatar Jul 20 '24 10:07 JeremyTBradshaw

@dmarquez1991 Per my understanding, the first interactive login fails for some reason. Could you see the popup window to select an account? If not, please upgrade to the latest Az.Accounts (3.0.2) to see whether the issue is fixed.

@hooverken @Technomancer-SysAdmin @JeremyTBradshaw @traberc Please try the latest Az.Accounts version. Your issue seems to the issue of elevated mode that we include the fix for.

msJinLei avatar Jul 22 '24 01:07 msJinLei

Same issue with version 3.0.2

ikishko avatar Jul 23 '24 20:07 ikishko

Same issue with version 3.0.2

@ikishko Could you create a github item and provide with the debug logs? thanks

msJinLei avatar Jul 24 '24 02:07 msJinLei

The issue may refer to the https://github.com/Azure/azure-powershell/issues/24989 and close it as a duplicate issue.

msJinLei avatar Aug 12 '24 03:08 msJinLei