janik6n / azlogin

Azure CLI login helper for multi-tenant users
Other
1 stars 0 forks source link
azure cli golang helpers

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.

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"

Configuration file location:

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