Closed samme78 closed 3 years ago
I was also in the process of moving my Visual Studio subscription from the old to the new account. So the first time I signed in to the new account I may not have had a subscription yet.
I've got the same issue. But in my case, the problems started after updating Azure Powershell to the newest version.
I installed latest powershell and azure versions, logged in with one azure account, then could not log off then login with second azure account
@samme78, thanks for reporting. could you please try to Connect-AzAccount
after you Clear-AzContext
?
I installed latest powershell and azure versions, logged in with one azure account, then could not log off then login with second azure account
@SolidRockProgrammer , are you meeting the same problem described by @samme78 ?
@samme78, thanks for reporting. could you please try to
Connect-AzAccount
after youClear-AzContext
?
running Clear-AzContext resolved my issue
I installed latest powershell and azure versions, logged in with one azure account, then could not log off then login with second azure account
@SolidRockProgrammer , are you meeting the same problem described by @samme78 ?
I thought so
In my case Clear-AzContext didn't work. Whatever command I try to use I either get:
The default context can no longer be found; please run 'Get-AzContext -ListAvailable' to see all available contexts, 'Select-AzContext' to select a new default context, or 'Connect-AzAccount' to login with a new account.
I also get the error when running Clear-AzContext. And I cannot do Connect-AzAccount afterwards.
PS C:\gitprojects\temp> Clear-AzContext
Confirm
Remove all accounts and subscriptions in all sessions for the current user?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
Clear-AzContext : The default context can no longer be found; please run 'Get-AzContext -ListAvailable' to see all av
ailable contexts, 'Select-AzContext' to select a new default context, or 'Connect-AzAccount' to login with a new acco
unt.
At line:1 char:1
+ Clear-AzContext
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Clear-AzContext], PSInvalidOperationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.Context.ClearAzureRmContext
PS C:\gitprojects\temp> Connect-AzAccount
Connect-AzAccount : The default context can no longer be found; please run 'Get-AzContext -ListAvailable' to see all
available contexts, 'Select-AzContext' to select a new default context, or 'Connect-AzAccount' to login with a new ac
count.
At line:1 char:1
+ Connect-AzAccount
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Connect-AzAccount], PSInvalidOperationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand
@samme78, @KacperMucha , could you please manually delete files .Azure\AzureRmContext.json
and .Azure\AzureRmContextSettings.json
under your user profile folder, normally your profile folder would be:
@erich-wang
It worked, after deleting .Azure\AzureRmContext.json
and .Azure\AzureRmContextSettings.json
I can once again run Connect-AzAccount.
Thank you
At first, after removing the files, I got:
Your Azure credentials have not been set up or have expired, please run Connect-AzAccount to set up your Azure credentials.
when I tried to reconnect. But then I tried Clean-AzContext and Connect-AzContext again, and I was able to run other commands too. One remark though. The test that succeeded was a bit different the previous ones. Earlier I was connecting with Connect-AzAccount -UseDeviceAuthentication -Scope Process, and this time I used only Connect-AzAccount without any parameters. Anyway thank for the tip @erich-wang.
delete files .Azure\AzureRmContext.json and .Azure\AzureRmContextSettings.json worked for me.
Thank you.
Deleteting the two files also worked for me.
Thanks everyone. Close this issue now. Please contact us if you have further question.
Description
I cannot connect to my azure account with the 'Connect-AzAccount' command. I get an error message saying the default context cannot be found. Basically all AZ commands return the same error message.
Steps to reproduce
I do not remember the exact steps I took to end up in this state but they were similar to this:
The two context visible below are tied to the old account.
Environment data
Module versions
Debug output
Error output