Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.21k stars 3.81k forks source link

Issue authenticating using Connect-AzAccount #25120

Closed dmarquez1991 closed 3 weeks ago

dmarquez1991 commented 3 months ago

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
hooverken commented 3 months ago

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
Technomancer-SysAdmin commented 2 months ago

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.

JeremyTBradshaw commented 2 months ago

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.

traberc commented 1 month ago

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.

JeremyTBradshaw commented 1 month ago

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 👴🤓

msJinLei commented 1 month ago

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

ikishko commented 1 month ago

Same issue with version 3.0.2

msJinLei commented 1 month ago

Same issue with version 3.0.2

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

msJinLei commented 3 weeks ago

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