az Verified current stable Not installed? Cloud Infrastructure

Az / Login Interactively

Login Interactively

Logs in to Azure interactively.

$
Terminal
az login

When To Use

During initial setup of new CLI environments or accounts.

Pro Tip

Utilize the '--tenant' flag to specify a particular tenant if your Azure account spans multiple tenants.

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
To sign in, visit: https://aka.ms/devicelogin

If prompted, enter the code: ABCD-EFGH

Anatomy of Output

Understanding the result

Logging in... Status

Indicates the login process has started.

Authenticated as user@example.com Current User

Confirms successful authentication.

Tenant ID: abcdef12-34gh-56ij-78kl-90mnopqrstu Tenant ID

Displays the tenant ID for context.

Power User Variants

Optimized versions

az login --tenant my-tenant-id

Log in to a specific tenant.

az login --username user@example.com --password mypassword

Log in using direct username and password.

Troubleshooting

Common pitfalls

LoginFailed: Unable to log in, incorrect credentials.

Solution: Verify the username and password used for authentication.

TenantNotFound: The specified tenant does not exist.

Solution: Ensure that the tenant ID is correct and exists in Azure.

NetworkError: Unable to connect to Azure services at this time.

Solution: Check your internet connection and Azure service status.

Command Breakdown

What each part is doing

az
Base Command
The executable that performs this operation. Here it runs Az before the shell applies any redirect operators.

How To Run

Execution path

  1. Step 1

    Run the command: `az login` in your terminal.

  2. Step 2

    Follow the on-screen instructions to authenticate using the provided URL.

Alternative Approaches

Comparable commands in other tools

Alternative cloud infrastructure tools for the same job.