LinuxCommandLibrary

az-logout

Sign out of Azure

TLDR

Log out from the active account

$ az logout
copy

Log out a specific username
$ az logout --username [alias@example.com]
copy

SYNOPSIS

az logout [--username]

PARAMETERS

--username
    Username (email) of the account to log out specifically.

DESCRIPTION

The az logout command is a key utility in the Azure Command-Line Interface (CLI), used to sign out from Azure accounts. It revokes access tokens for the specified or default account, preventing further authenticated operations until re-login.

Ideal for maintaining security on shared systems, switching users, or ending sessions. Without the --username option, it targets the primary account if multiple are logged in (viewable via az account list). Providing --username allows selective logout.

Post-logout, Azure CLI prompts for re-authentication on commands needing it. Note: subscriptions may linger in cache; use az account clear for complete reset. This command ensures compliance with least-privilege access, vital for enterprise environments managing cloud resources efficiently.

CAVEATS

Does not clear cached subscriptions; pair with az account clear if needed. Multiple accounts require explicit --username for non-primary logout.

EXAMPLES

az logout # Log out default account
az logout --username user@contoso.com # Log out specific user

HISTORY

Introduced in Azure CLI 2.0 (2017) as part of unified account management, evolving with multi-account support in later versions.

SEE ALSO

az login(1), az account list(1), az account clear(1)

Copied to clipboard