To get the connected user account with the Azure CLI, you need to use the below command.
PS C:\> az account show
Once you type the command, you will get the output in JSON format as shown below.
PS C:\> az account show { "environmentName": "AzureCloud", "homeTenantId": "Your tenant ID", "id": "Subscriptio ID", "isDefault": true, "managedByTenants": [], "name": "Subscription Name", "state": "Enabled", "tenantId": "tenant ID", "user": { "name": "user logged in email id or username", "type": "user" } }
To get the output in the table format, use the -otable or –output table
PS C:\> az account show -otable