Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
373 stars 168 forks source link

Feature Show Logged in account email or client ID for `azd auth login` and `azd auth login --check-status` #2856

Open john0isaac opened 7 months ago

john0isaac commented 7 months ago

closes #1745

Full flow of azd auth login and azd auth login --check-status with normal account

image

Full flow of azd auth login and azd auth login --check-status with service principal

image

john0isaac commented 7 months ago

@ellismg I learned about service principal and handled their exception. image

john0isaac commented 7 months ago

(L343) This is the line that gets triggered to print the service principal client ID note that in the screen shot that I shared before I was trying to log in not trying to check-status that's why it's not consistent in the code. image

Let me think about it and get back to you, I found that there is a difference between logging in and checking the status so, I will try to make the whole code more consistent as it's as confusing to me as it is to you.

Update 1:

In this commit https://github.com/Azure/azure-dev/pull/2856/commits/dc1b59bcc0835c288f84974d0118f747b1cbf195 I added the feature to display the logged in user email or service principal on successful login to make the code consistent

output of command azd auth login for normal account image

output of command azd auth login for service principal image

Currently trying to figure out how to get the service principal client id from something other than the flags to display it on the ---check-status output

Update 2:

I couldn't get the client id when a service principal account loggs in so, I implemented a new function in the auth.Manager to get it. https://github.com/Azure/azure-dev/pull/2856/commits/f3f830a379dd806d63229df40a83e57f24356c21 Suggestion: In the auth.Manager.GetSignedInAccount(ctx) we can return the currentUser.ClientID instead of returning nil but I didn't know the implications of doing this so, I opted for the safe path which is to leave it as it us and create a new function. (Can't we return it in the GetSignedInAccount?)

Full flow of azd auth login and azd auth login --check-status with normal account

image

Full flow of azd auth login and azd auth login --check-status with service principal

image