Skip to content

Instantly share code, notes, and snippets.

@clarenceb
Created February 20, 2024 22:21
Show Gist options
  • Save clarenceb/f44a6e808bbd6a57a3a5e1f552fa5c78 to your computer and use it in GitHub Desktop.
Save clarenceb/f44a6e808bbd6a57a3a5e1f552fa5c78 to your computer and use it in GitHub Desktop.
WSL2 login to Azure Subscription for Azure CLI using Windows browser and Azure AD SSO
#!/bin/bash
TENANT="<your-tenant>.onmicrosoft.com"
SUBSCRIPTION_ID="<your-azure-subscription-id>"
BROWSER="/usr/bin/wslview"
export BROWSER
# Fix WSL2 clock synchronisation drift which commonly occurs
sudo ntpdate pool.ntp.org
az login --tenant $TENANT
az account set -s $SUBSCRIPTION_ID
banner Resource Groups
az group list -o table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment