miniguide

Azure Login & Certificates Cheatsheet: Authentication and Troubleshooting

Introduction

This cheatsheet provides Azure CLI examples for logging into Azure, including interactive login, service principal login using certificates, and various troubleshooting examples.

Table of Contents

1. Interactive Login

az login

2. Login with Service Principal & Password

az login --service-principal --username <appId> --password <password> --tenant <tenantId>

3. Login with Service Principal & Certificate

az login --service-principal --username <appId> --password <path/to/certificate.pem> --tenant <tenantId>

4. Login Using Device Code

az login --use-device-code

5. List Current Account

az account show

6. Show Login Information

az ad signed-in-user show

7. Logout from Azure

az logout

8. Troubleshoot Login Issues

Example: Retry login with verbose output.

az login --debug

9. Validate Certificate Authentication

Example: Check certificate details used in login.

az ad sp credential list --id <appId>

10. Use Environment Variables for Login

Example: Export variables then login.

export AZURE_CLIENT_ID=<appId>
export AZURE_TENANT_ID=<tenantId>
export AZURE_CLIENT_SECRET=<secret>
az login --service-principal