How to access AAD B2C tenant with Azure CLI

Viewed 2689

I need to get user details in AAD B2C tenant I have access to:

az ad user show --id 0cbb4fd6-7091-44fb-ab5e-d2bd9c366f59

This cannot find the user because I'm logged into my organization regular AAD tenant. B2C tenants do not have subscriptions, they're linked to the primary tenant which means I can't do

az login -t myb2ctenant.onmicrosoft.com

Working in the portal isn't handy, I'd like to do my routines in CLI. How can I do that?

1 Answers

There is an option on the AZ CLI to access tenants without subscriptions. Change your command to:

az login -t myb2ctenant.onmicrosoft.com --allow-no-subscriptions

Explanation from az login -h:

Support access tenants without subscriptions. It's uncommon but useful to run tenant level commands, such as 'az ad'.

Related