azctx

command module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2026 License: MIT Imports: 6 Imported by: 0

README

azctx

Last Commit Open Issues

A CLI tool for managing Azure CLI contexts, modelled after kubectx. It maintains a composable config file that maps named contexts to a tenant, credential, and optional subscription. Running azctx use <name> switches the active context and syncs the Azure CLI session via az login and az account set.

Installation

Homebrew
brew install lvlcn-t/tap/azctx
go install

Requires Go 1.26+ and the GOEXPERIMENT=jsonv2 flag:

GOEXPERIMENT=jsonv2 go install github.com/lvlcn-t/azctx@latest
Manual

Download the archive for your platform from the releases page, extract the binary, and place it on your PATH.

Linux / macOS:

OS=$(uname -s)
ARCH=$(uname -m | sed 's/aarch64/arm64/')
curl -sL "https://github.com/lvlcn-t/azctx/releases/latest/download/azctx_${OS}_${ARCH}.tar.gz" \
  | tar -xz -C ~/.local/bin azctx
chmod +x ~/.local/bin/azctx

Windows (PowerShell):

$arch = if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") { "x86_64" } else { "arm64" }
$url = "https://github.com/lvlcn-t/azctx/releases/latest/download/azctx_Windows_$arch.zip"
Invoke-WebRequest $url -OutFile azctx.zip
Expand-Archive azctx.zip -DestinationPath .
Move-Item azctx.exe "$env:LOCALAPPDATA\Microsoft\WindowsApps\azctx.exe"
Container Image

Pre-built images are published to GitHub Container Registry:

docker pull ghcr.io/lvlcn-t/azctx:latest
docker run --rm \
  -v ~/.config/azctx:/home/nonroot/.config/azctx \
  -v ~/.azure:/home/nonroot/.azure \
  ghcr.io/lvlcn-t/azctx:latest use dev-west

Available tags: latest, vMAJOR, vMAJOR.MINOR, and full semver.

Quick start

Create a minimal config at ~/.config/azctx/config.yaml:

tenants:
  - name: dev
    id: 00000000-0000-0000-0000-000000000000

credentials:
  - name: personal
    credential:
      type: user
      azure: {}

contexts:
  - name: dev
    context:
      tenant: dev
      credential: personal

Then switch to it:

azctx use dev        # opens browser for login, sets subscription
azctx current        # prints "dev"
azctx list -o table  # show all contexts

Documentation

Guide Description
Configuration Config file format, credential types, Key Vault references
Workload Identity OIDC federation — OAuth2 PKCE and file-based tokens
Usage All commands, output formats, typical workflows
CLI Reference Auto-generated command documentation
Contributing Development setup, testing, PR guidelines

License

Copyright (c) 2024 lvlcn-t. Licensed under the MIT License.

Code of Conduct

This project has adopted the Contributor Covenant v2.1. All contributors must abide by the code of conduct.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package az provides integrations with the Azure CLI.
Package az provides integrations with the Azure CLI.
Package cmd contains the command-line interface (CLI) commands for the azctx CLI.
Package cmd contains the command-line interface (CLI) commands for the azctx CLI.
Package config provides loading, merging, validating, and writing azctx config.
Package config provides loading, merging, validating, and writing azctx config.
internal
gendoc command
Package main generates CLI reference documentation into docs/reference/.
Package main generates CLI reference documentation into docs/reference/.
Package keyvault resolves keyvault:// URI references to their secret or certificate values using Azure SDK and ambient credentials.
Package keyvault resolves keyvault:// URI references to their secret or certificate values using Azure SDK and ambient credentials.
Package output provides shared renderers for text, table, and JSON output.
Package output provides shared renderers for text, table, and JSON output.
wif
Package wif provides federated identity token acquisition for Azure workload identity login.
Package wif provides federated identity token acquisition for Azure workload identity login.
factory
Package factory creates wif.Provider instances based on credential configuration.
Package factory creates wif.Provider instances based on credential configuration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL