-
Notifications
You must be signed in to change notification settings - Fork 4k
Get-AzContext doesn't always grab the UPN #15181
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
Comments
Thanks for reporting. The account name may be different from UPN. We didn't find clear rule between account id for login and UPN from AAD graph or MSGraph. Is there any official doc? |
The only docs I see is the following: It looks to be a legacy issue with I have asked several people to see if they can reproduce this, but everything works as normal. It might be an issue with Service Principles or Guest Accounts. Will verify with I was told this method works in Bash with no issue. #sign into AZ CLI, this will redirect you to a web browser for authentication, if required
az login
#assign Owner role to Tenant root scope ("/") as a Owner (gets object Id of the current user (az login))
az role assignment create --scope '/' --role 'Owner' --assignee-object-id $(az ad signed-in-user show --query objectId) |
Our proposal is |
please try above suggestion, close this issue for now. |
Oh boy, I really wish this would work using Azure Powershell. Using Azure CLI as a workaround really doesn't work too well when trying to integrate with other scripts. In my example, my Microsoft account is linked with my personal e-mail address. It produces a UPN that looks something like However, note the results of the following commands using Azure Powershell: (Get-AzContext).Account.Id
# returns '{my email}@gmail.com'
(Get-AzContext).Account.Type
# returns 'User' I am trying to create a script that assigns Key Vault access policies dynamically to the executing user, but this makes it nearly impossible for this type of account scenario as I don't believe there is any good way to assign it without hardcoding a |
@adamasmar , thanks for contacting us. Please try to use |
Uh oh!
There was an error while loading. Please reload this page.
Description
This might be a duplicate, but creating it for an issue tracker product. Azure/Enterprise-Scale#601
Get-AzContext
doesn't always grab the UPN.#13797
Steps to reproduce
The text was updated successfully, but these errors were encountered: