Skip to main content

az_account_show()

The Azure CLI’s current account, from az account show --output json.

Usage

Source

az_account_show(timeout=_TIMEOUT)

Parameters

timeout: float | None = _TIMEOUT
Seconds to wait for az; None waits as long as it takes.

Returns

dict
The account as az prints it: id (the subscription), name, tenantId, user (with name and type) and the rest.

Raises

AzCliNotLoggedInError

The CLI is not logged in.

AzCliNotFoundError

There is no az on PATH.

AzCliTimeoutError

az did not finish within timeout seconds.

AzCliError
Any other failure, with what az wrote to stderr.

Notes

Runs the az that shutil.which("az") finds, as a plain subprocess (ported from azr’s az_cli_*() helpers). For tokens from the CLI, use azure.identity.AzureCliCredential, which dazapiz does not wrap.

Examples

from dazapiz import az_account_show

account = az_account_show()
account["user"]["name"], account["tenantId"]