Skip to content
janik6nPublic

About

Azure CLI login helper for multi-tenant users

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

Go Azure

Azlogin

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.

Features

  • Login to Azure CLI: Choose a tenant by name from your configuration and run az login for 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=true to run the menus in accessible mode.

Prerequisites

Azure CLI v2 is expected to be installed and configured.

Configuration

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|false

Configuration file location:

  • If the environment is DEV: ./configuration.yaml. You also need to set environment variable ENVIRONMENT=DEV.
  • If the environment is PROD: $HOME/azlogin/configuration.yaml in macOS/Linux and %USERPROFILE%\azlogin\configuration.yaml in Windows.

Logging

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.

Run binary release

With the binary releases all you need is the configuration file described above and a binary for your platform.

⚠️ The binaries in each release are built with GoReleaser and GitHub Actions. They are not signed or notarized, so warnings may arise when you run the app. Run at your own risk.

How to run in dev

Before installing:

ENVIRONMENT=DEV go run cmd/azlogin/main.go

Build and install

Build, 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.sh

The binary will be installed to location defined in .zshrc:

export PATH="$HOME/go/bin:$PATH"

Automation

New GitHub Release is created with GoReleaser and GitHub Actions when a new tag is pushed to the repository.

References

Packages used

Changelog

CHANGELOG

License

MIT

About

Azure CLI login helper for multi-tenant users

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages