Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add-AzureAccount does not create TokenCache.dat #4080

Closed
afengli opened this issue Jun 6, 2017 · 6 comments
Closed

Add-AzureAccount does not create TokenCache.dat #4080

afengli opened this issue Jun 6, 2017 · 6 comments

Comments

@afengli
Copy link

afengli commented Jun 6, 2017

Cmdlet(s)

PowerShell Version

Instructions: to get PowerShell version, type $PSVersionTable and look for the value associated with PSVersion

5.1.14393.1198

Module Version

4.0.2

OS Version

Instructions: to get OS version, type $PSversionTable and look for value associated with BuildVersion
10.0.14393.1198

Description

Add-AzureAccount does not create TokenCache.dat. This will cause command like Get-AzureService to fail.

Debug Output

Instructions: to get Debug Output, set $DebugPreference="Continue" and then execute the cmdlet or script causing the issue

Script/Steps for Reproduction

Try this script:

# Set User and Password
$AzureName = "user@domain.onmicrosoft.com"

$AzurePassword = ConvertTo-SecureString 'Password' -AsPlainText -Force

# Get Credential Object
$AzureRMCredential = New-Object -TypeName System.Management.Automation.PSCredential($AzureName, $AzurePassword)


# Removing Azure Account (Classic)
Write-Host "Executing Remove-AzureAccount and Clear-AzureProfile (Classic)..."
Get-AzureAccount | ForEach-Object { Remove-AzureAccount $_.ID -Force }
Clear-AzureProfile -Force

# Add Azure account for classic resources
Write-Host "Executing Add-AzureAccount (Classic)..."
Add-AzureAccount -Credential $AzureRMCredential -Verbose
#Login-AzureRmAccount -Credential $AzureRMCredential -Verbose

Select-AzureSubscription -SubscriptionId 'be8b8d49-5fe4-4abb-bac1-xxxxxxxxxxxx'

Get-AzureService -Debug
@afengli
Copy link
Author

afengli commented Jun 6, 2017

some more information. debug shows the call Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache.AfterAccessNotification was not called during the token creation.

Even for this one Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache..ctor(Byte[])

@cormacpayne
Copy link
Member

cormacpayne commented Jun 9, 2017

@afengli would you mind providing us with the debug output when executing this cmdlet? You can do so by setting $DebugPreference=Continue before executing the set of cmdlets.

Also do you have permissions to read/write in "AppData/Roaming/Windows Azure PowerShell"?

@cormacpayne cormacpayne added this to the July 2017 milestone Jun 9, 2017
@afengli
Copy link
Author

afengli commented Jun 9, 2017

@cormacpayne , yes I am doing it. you can also try to reproduce it easily. I see multiple instances that the 4.x version module broke the authentication and Azure context.

@afengli
Copy link
Author

afengli commented Jun 9, 2017

@cormacpayne
Adding "$DebugPreference=Continue" does not give more output. There is no permission restriction on th e folder.

@markcowl
Copy link
Member

@afengli We have found the root cause - if you don't have a TokenCache.dat file already, it is not creat6ed at startup. Filed an issue here: #4144 to fix in the current milestone

@markcowl
Copy link
Member

Fixed. Will ship in in July release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants