Azure CLI login helper. You have multiple tenants to login to, but cannot remember the tenant IDs? Azlogin to the rescue!
Functionally & securitywise there is nothing too special; This is just a wrapper for Azure CLI. All the information stored about your tenants is defined below, and all the information is provided by you.
Running the app with the selected tenant will trigger az login flow for the selected tenant, and that's it.
If you have configured select_subscription: true, a Subscription selection will be run after successful login.
- Login to Azure CLI: Choose a tenant by name from your configuration and run
az loginfor it. Tenants can be configured by tenant ID or domain name. - Session reuse: If Azure CLI still has a valid session for the selected tenant, the existing session is reused and that tenant is made active, skipping
az login. - Subscription selection after login: With
select_subscription: true, choose a Subscription of the logged-in tenant right after login. The Subscription list is searchable. - Select subscription: Change the Subscription within the current tenant without logging in again. If you are not logged in, you are asked to log in first.
- Show current login: Show the current Subscription, tenant and user.
- Logout: Log out the current account, or all accounts.
- About: Show the app version and a link to the changelog.
- Accessible mode: Set environment variable
ACCESSIBLE=trueto run the menus in accessible mode.
Azure CLI v2 is expected to be installed and configured.
Configuration is handled in configuration.yaml
general:
environment: DEV|PROD
logging: true|false
logging_level: INFO|WARNING|ERROR|FATAL
print_config: true|false
features:
azlogin:
tenants:
- tenant_name: "Alpha"
tenant_id: "alpha.onmicrosoft.com"
- tenant_name: "Bravo"
tenant_id: "23456-23456"
select_subscription: true|falseConfiguration file location:
- If the
environmentisDEV:./configuration.yaml. You also need to set environment variableENVIRONMENT=DEV. - If the
environmentisPROD:$HOME/azlogin/configuration.yamlin macOS/Linux and%USERPROFILE%\azlogin\configuration.yamlin Windows.
The app optionally logs to a file ./azlogin.log for DEV and to $HOME/azlogin/azlogin.log in macOS/Linux or %USERPROFILE%\azlogin/azlogin.log in Windows for PROD.
With the binary releases all you need is the configuration file described above and a binary for your platform.
Before installing:
ENVIRONMENT=DEV go run cmd/azlogin/main.goBuild, and installation, must be done where the main package is located.
# To build
cd cmd/azlogin
# For architecture where developed:
go build -o "../../build/azlogin"
# For macOS ARM64
GOARCH=arm64 GOOS=darwin go build -o "../../build/azlogin"
# For Windows AMD64
GOARCH=amd64 GOOS=windows go build -o "../../build/azlogin.exe"There is a little helper script available for installation on macOS & ZSH. To install, run in project root:
# Runs the build too.
./install_azlogin.shThe binary will be installed to location defined in .zshrc:
export PATH="$HOME/go/bin:$PATH"New GitHub Release is created with GoReleaser and GitHub Actions when a new tag is pushed to the repository.
- https://github.com/Azure/azure-sdk-for-go (License: MIT)
- https://github.com/charmbracelet/huh for terminal UI (License: MIT)
- https://github.com/charmbracelet/huh/spinner for terminal UI (License: MIT)
- https://github.com/charmbracelet/lipgloss for terminal UI (License: MIT)
- https://github.com/go-yaml/yaml for reading and writing YAML files (License: MIT & Apache 2.0)
- https://github.com/natefinch/lumberjack for logging (License: MIT)