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.
Command: Login using a personal access token (PAT).
az devops login --token <PAT>
Command: Set the default Azure DevOps organization.
az devops configure --defaults organization=https://dev.azure.com/<orgName>
Command: Verify current configuration settings.
az devops configure --list
Command: Login to Microsoft 365 using the CLI.
m365 login
Command: Logout from Microsoft 365.
m365 logout
Command: Logout from Azure DevOps (clear token).
az devops logout
Example: Retry login with verbose output for troubleshooting.
az devops login --token <PAT> --debug
Example: Show detailed error during m365 login.
m365 login --debug
Example: Store PAT in an environment variable and login.
export AZDO_PAT=<PAT>
az devops login --token $AZDO_PAT
Command: Display account information after login.
az account show