Getting tenant name from azure CLI
I would like to retrieve the tenant name THIS-THING-HERE.onmicrosoft.com
using Azure CLI. I can't really find in documentation.
EDIT:
When I'm calling azure account list I don't get user name in the domain provided since I'm login with corporate email:
[
"cloudName": "AzureCloud",
"id": "46ee2f65-7112-4c96-ad0a-3ff6ca22a615",
"isDefault": true,
"name": "Visual Studio Professional",
"state": "Enabled",
"tenantId": "1caf5d6b-58cb-40e6-88b3-eb9ab9c0c010",
"user":
"name": "a.krajniak@avanade.com",
"type": "user"
,
"cloudName": "AzureCloud",
"id": "1efd84d6-173f-42cc-80db-7b2c17eb0edd",
"isDefault": false,
"name": "Microsoft Azure Enterprise",
"state": "Enabled",
"tenantId": "c48d02ad-7efd-4910-9b51-ebb7a4b75379",
"user":
"name": "a.krajniak@avanade.com",
"type": "user"
]
azure azure-cli
add a comment |
I would like to retrieve the tenant name THIS-THING-HERE.onmicrosoft.com
using Azure CLI. I can't really find in documentation.
EDIT:
When I'm calling azure account list I don't get user name in the domain provided since I'm login with corporate email:
[
"cloudName": "AzureCloud",
"id": "46ee2f65-7112-4c96-ad0a-3ff6ca22a615",
"isDefault": true,
"name": "Visual Studio Professional",
"state": "Enabled",
"tenantId": "1caf5d6b-58cb-40e6-88b3-eb9ab9c0c010",
"user":
"name": "a.krajniak@avanade.com",
"type": "user"
,
"cloudName": "AzureCloud",
"id": "1efd84d6-173f-42cc-80db-7b2c17eb0edd",
"isDefault": false,
"name": "Microsoft Azure Enterprise",
"state": "Enabled",
"tenantId": "c48d02ad-7efd-4910-9b51-ebb7a4b75379",
"user":
"name": "a.krajniak@avanade.com",
"type": "user"
]
azure azure-cli
add a comment |
I would like to retrieve the tenant name THIS-THING-HERE.onmicrosoft.com
using Azure CLI. I can't really find in documentation.
EDIT:
When I'm calling azure account list I don't get user name in the domain provided since I'm login with corporate email:
[
"cloudName": "AzureCloud",
"id": "46ee2f65-7112-4c96-ad0a-3ff6ca22a615",
"isDefault": true,
"name": "Visual Studio Professional",
"state": "Enabled",
"tenantId": "1caf5d6b-58cb-40e6-88b3-eb9ab9c0c010",
"user":
"name": "a.krajniak@avanade.com",
"type": "user"
,
"cloudName": "AzureCloud",
"id": "1efd84d6-173f-42cc-80db-7b2c17eb0edd",
"isDefault": false,
"name": "Microsoft Azure Enterprise",
"state": "Enabled",
"tenantId": "c48d02ad-7efd-4910-9b51-ebb7a4b75379",
"user":
"name": "a.krajniak@avanade.com",
"type": "user"
]
azure azure-cli
I would like to retrieve the tenant name THIS-THING-HERE.onmicrosoft.com
using Azure CLI. I can't really find in documentation.
EDIT:
When I'm calling azure account list I don't get user name in the domain provided since I'm login with corporate email:
[
"cloudName": "AzureCloud",
"id": "46ee2f65-7112-4c96-ad0a-3ff6ca22a615",
"isDefault": true,
"name": "Visual Studio Professional",
"state": "Enabled",
"tenantId": "1caf5d6b-58cb-40e6-88b3-eb9ab9c0c010",
"user":
"name": "a.krajniak@avanade.com",
"type": "user"
,
"cloudName": "AzureCloud",
"id": "1efd84d6-173f-42cc-80db-7b2c17eb0edd",
"isDefault": false,
"name": "Microsoft Azure Enterprise",
"state": "Enabled",
"tenantId": "c48d02ad-7efd-4910-9b51-ebb7a4b75379",
"user":
"name": "a.krajniak@avanade.com",
"type": "user"
]
azure azure-cli
azure azure-cli
edited Nov 14 '18 at 8:08
Dzior
asked Nov 13 '18 at 10:38
DziorDzior
599316
599316
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You could use this command:
az ad signed-in-user show --query 'userPrincipalName' | cut -d '@' -f 2 | sed 's/"//'
this will take user upn and take the last part
I'm gettingaz ad: 'signed-in-user' is not in the 'az ad' command group. See 'az ad --help'
– Dzior
Nov 14 '18 at 8:04
update your azure cli, or use any other place where it shows your upn, likeaz account show
– 4c74356b41
Nov 14 '18 at 8:27
I've update my azure cli on my mac, still the same. Also I searched for this command in documentation without any luck
– Dzior
Nov 14 '18 at 10:28
like i said, use another query:az account show --query 'user.name' | cut -d '@' -f 2 | sed 's/"//'
– 4c74356b41
Nov 14 '18 at 11:01
add a comment |
To retrieve tenant name:
In the Azure CLI (I use GNU/Linux):
$ azure login # add "-e AzureChinaCloud" if you're using Azure China
This will ask you to login via https://aka.ms/devicelogin or https://aka.ms/deviceloginchina
$ azure account show
"environmentName": "AzureCloud",
"id": "aaabbbcccdd-eeff-gghh-iijj-abcdef256984",
"isDefault": true,
"name": "MSDN Subscription",
"state": "Enabled",
"tenantId": "ggzzttyyh-56rg-op4e-iixx-kiednd256",
"user":
"cloudShellID": true,
"name": "paul@xxx.onmicrosoft.com",
"type": "user"
To get tenant ID:
az account list | jq -r '..tenantId'
To get tenant name:
az account list | jq -r '..user'.name
I hope it helps
That doesn't work for me, look at the edit please
– Dzior
Nov 14 '18 at 8:09
Useaz ad signed-in-user show --query 'userPrincipalName'
– Paul Oyemakinwa
Nov 14 '18 at 9:56
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279143%2fgetting-tenant-name-from-azure-cli%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could use this command:
az ad signed-in-user show --query 'userPrincipalName' | cut -d '@' -f 2 | sed 's/"//'
this will take user upn and take the last part
I'm gettingaz ad: 'signed-in-user' is not in the 'az ad' command group. See 'az ad --help'
– Dzior
Nov 14 '18 at 8:04
update your azure cli, or use any other place where it shows your upn, likeaz account show
– 4c74356b41
Nov 14 '18 at 8:27
I've update my azure cli on my mac, still the same. Also I searched for this command in documentation without any luck
– Dzior
Nov 14 '18 at 10:28
like i said, use another query:az account show --query 'user.name' | cut -d '@' -f 2 | sed 's/"//'
– 4c74356b41
Nov 14 '18 at 11:01
add a comment |
You could use this command:
az ad signed-in-user show --query 'userPrincipalName' | cut -d '@' -f 2 | sed 's/"//'
this will take user upn and take the last part
I'm gettingaz ad: 'signed-in-user' is not in the 'az ad' command group. See 'az ad --help'
– Dzior
Nov 14 '18 at 8:04
update your azure cli, or use any other place where it shows your upn, likeaz account show
– 4c74356b41
Nov 14 '18 at 8:27
I've update my azure cli on my mac, still the same. Also I searched for this command in documentation without any luck
– Dzior
Nov 14 '18 at 10:28
like i said, use another query:az account show --query 'user.name' | cut -d '@' -f 2 | sed 's/"//'
– 4c74356b41
Nov 14 '18 at 11:01
add a comment |
You could use this command:
az ad signed-in-user show --query 'userPrincipalName' | cut -d '@' -f 2 | sed 's/"//'
this will take user upn and take the last part
You could use this command:
az ad signed-in-user show --query 'userPrincipalName' | cut -d '@' -f 2 | sed 's/"//'
this will take user upn and take the last part
answered Nov 13 '18 at 12:25
4c74356b414c74356b41
25.3k42050
25.3k42050
I'm gettingaz ad: 'signed-in-user' is not in the 'az ad' command group. See 'az ad --help'
– Dzior
Nov 14 '18 at 8:04
update your azure cli, or use any other place where it shows your upn, likeaz account show
– 4c74356b41
Nov 14 '18 at 8:27
I've update my azure cli on my mac, still the same. Also I searched for this command in documentation without any luck
– Dzior
Nov 14 '18 at 10:28
like i said, use another query:az account show --query 'user.name' | cut -d '@' -f 2 | sed 's/"//'
– 4c74356b41
Nov 14 '18 at 11:01
add a comment |
I'm gettingaz ad: 'signed-in-user' is not in the 'az ad' command group. See 'az ad --help'
– Dzior
Nov 14 '18 at 8:04
update your azure cli, or use any other place where it shows your upn, likeaz account show
– 4c74356b41
Nov 14 '18 at 8:27
I've update my azure cli on my mac, still the same. Also I searched for this command in documentation without any luck
– Dzior
Nov 14 '18 at 10:28
like i said, use another query:az account show --query 'user.name' | cut -d '@' -f 2 | sed 's/"//'
– 4c74356b41
Nov 14 '18 at 11:01
I'm getting
az ad: 'signed-in-user' is not in the 'az ad' command group. See 'az ad --help'
– Dzior
Nov 14 '18 at 8:04
I'm getting
az ad: 'signed-in-user' is not in the 'az ad' command group. See 'az ad --help'
– Dzior
Nov 14 '18 at 8:04
update your azure cli, or use any other place where it shows your upn, like
az account show
– 4c74356b41
Nov 14 '18 at 8:27
update your azure cli, or use any other place where it shows your upn, like
az account show
– 4c74356b41
Nov 14 '18 at 8:27
I've update my azure cli on my mac, still the same. Also I searched for this command in documentation without any luck
– Dzior
Nov 14 '18 at 10:28
I've update my azure cli on my mac, still the same. Also I searched for this command in documentation without any luck
– Dzior
Nov 14 '18 at 10:28
like i said, use another query:
az account show --query 'user.name' | cut -d '@' -f 2 | sed 's/"//'
– 4c74356b41
Nov 14 '18 at 11:01
like i said, use another query:
az account show --query 'user.name' | cut -d '@' -f 2 | sed 's/"//'
– 4c74356b41
Nov 14 '18 at 11:01
add a comment |
To retrieve tenant name:
In the Azure CLI (I use GNU/Linux):
$ azure login # add "-e AzureChinaCloud" if you're using Azure China
This will ask you to login via https://aka.ms/devicelogin or https://aka.ms/deviceloginchina
$ azure account show
"environmentName": "AzureCloud",
"id": "aaabbbcccdd-eeff-gghh-iijj-abcdef256984",
"isDefault": true,
"name": "MSDN Subscription",
"state": "Enabled",
"tenantId": "ggzzttyyh-56rg-op4e-iixx-kiednd256",
"user":
"cloudShellID": true,
"name": "paul@xxx.onmicrosoft.com",
"type": "user"
To get tenant ID:
az account list | jq -r '..tenantId'
To get tenant name:
az account list | jq -r '..user'.name
I hope it helps
That doesn't work for me, look at the edit please
– Dzior
Nov 14 '18 at 8:09
Useaz ad signed-in-user show --query 'userPrincipalName'
– Paul Oyemakinwa
Nov 14 '18 at 9:56
add a comment |
To retrieve tenant name:
In the Azure CLI (I use GNU/Linux):
$ azure login # add "-e AzureChinaCloud" if you're using Azure China
This will ask you to login via https://aka.ms/devicelogin or https://aka.ms/deviceloginchina
$ azure account show
"environmentName": "AzureCloud",
"id": "aaabbbcccdd-eeff-gghh-iijj-abcdef256984",
"isDefault": true,
"name": "MSDN Subscription",
"state": "Enabled",
"tenantId": "ggzzttyyh-56rg-op4e-iixx-kiednd256",
"user":
"cloudShellID": true,
"name": "paul@xxx.onmicrosoft.com",
"type": "user"
To get tenant ID:
az account list | jq -r '..tenantId'
To get tenant name:
az account list | jq -r '..user'.name
I hope it helps
That doesn't work for me, look at the edit please
– Dzior
Nov 14 '18 at 8:09
Useaz ad signed-in-user show --query 'userPrincipalName'
– Paul Oyemakinwa
Nov 14 '18 at 9:56
add a comment |
To retrieve tenant name:
In the Azure CLI (I use GNU/Linux):
$ azure login # add "-e AzureChinaCloud" if you're using Azure China
This will ask you to login via https://aka.ms/devicelogin or https://aka.ms/deviceloginchina
$ azure account show
"environmentName": "AzureCloud",
"id": "aaabbbcccdd-eeff-gghh-iijj-abcdef256984",
"isDefault": true,
"name": "MSDN Subscription",
"state": "Enabled",
"tenantId": "ggzzttyyh-56rg-op4e-iixx-kiednd256",
"user":
"cloudShellID": true,
"name": "paul@xxx.onmicrosoft.com",
"type": "user"
To get tenant ID:
az account list | jq -r '..tenantId'
To get tenant name:
az account list | jq -r '..user'.name
I hope it helps
To retrieve tenant name:
In the Azure CLI (I use GNU/Linux):
$ azure login # add "-e AzureChinaCloud" if you're using Azure China
This will ask you to login via https://aka.ms/devicelogin or https://aka.ms/deviceloginchina
$ azure account show
"environmentName": "AzureCloud",
"id": "aaabbbcccdd-eeff-gghh-iijj-abcdef256984",
"isDefault": true,
"name": "MSDN Subscription",
"state": "Enabled",
"tenantId": "ggzzttyyh-56rg-op4e-iixx-kiednd256",
"user":
"cloudShellID": true,
"name": "paul@xxx.onmicrosoft.com",
"type": "user"
To get tenant ID:
az account list | jq -r '..tenantId'
To get tenant name:
az account list | jq -r '..user'.name
I hope it helps
answered Nov 13 '18 at 12:53
Paul OyemakinwaPaul Oyemakinwa
11
11
That doesn't work for me, look at the edit please
– Dzior
Nov 14 '18 at 8:09
Useaz ad signed-in-user show --query 'userPrincipalName'
– Paul Oyemakinwa
Nov 14 '18 at 9:56
add a comment |
That doesn't work for me, look at the edit please
– Dzior
Nov 14 '18 at 8:09
Useaz ad signed-in-user show --query 'userPrincipalName'
– Paul Oyemakinwa
Nov 14 '18 at 9:56
That doesn't work for me, look at the edit please
– Dzior
Nov 14 '18 at 8:09
That doesn't work for me, look at the edit please
– Dzior
Nov 14 '18 at 8:09
Use
az ad signed-in-user show --query 'userPrincipalName'
– Paul Oyemakinwa
Nov 14 '18 at 9:56
Use
az ad signed-in-user show --query 'userPrincipalName'
– Paul Oyemakinwa
Nov 14 '18 at 9:56
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279143%2fgetting-tenant-name-from-azure-cli%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown