miniguide

Azure DevOps & Microsoft 365 Login Cheatsheet: Terminal Authentication

Introduction

This cheatsheet provides essential commands for logging into Azure DevOps and Microsoft 365 from the terminal, along with troubleshooting steps. It is designed for DevOps professionals to manage and troubleshoot authentication.

Table of Contents

  1. Azure DevOps Login
  2. Set Azure DevOps Organization
  3. Verify Azure DevOps Settings
  4. Microsoft 365 Login via CLI
  5. Microsoft 365 Logout
  6. Azure DevOps Logout
  7. Troubleshoot DevOps Login
  8. Troubleshoot M365 Login
  9. Use PAT for DevOps Login
  10. View Account Info

1. Azure DevOps Login

Command: Login using a personal access token (PAT).

az devops login --token <PAT>

2. Set Azure DevOps Organization

Command: Set the default Azure DevOps organization.

az devops configure --defaults organization=https://dev.azure.com/<orgName>

3. Verify Azure DevOps Settings

Command: Verify current configuration settings.

az devops configure --list

4. Microsoft 365 Login via CLI

Command: Login to Microsoft 365 using the CLI.

m365 login

5. Microsoft 365 Logout

Command: Logout from Microsoft 365.

m365 logout

6. Azure DevOps Logout

Command: Logout from Azure DevOps (clear token).

az devops logout

7. Troubleshoot DevOps Login

Example: Retry login with verbose output for troubleshooting.

az devops login --token <PAT> --debug

8. Troubleshoot M365 Login

Example: Show detailed error during m365 login.

m365 login --debug

9. Use PAT for DevOps Login

Example: Store PAT in an environment variable and login.

export AZDO_PAT=<PAT>
az devops login --token $AZDO_PAT

10. View Account Info

Command: Display account information after login.

az account show