Skip to main content

Switch Azure subscriptions

[!WARNING] The new version of the Azure-CLI, since 2.61.0, has build-in support for switching subscriptions, so this package is no longer needed. You can use the command az login to switch subscriptions directly. See: https://learn.microsoft.com/en-us/cli/azure/authenticate-azure-cli-interactively?view=azure-cli-latest#subscription-selector.

[License](

Type Badge
Workflow Test !Workflow upload
Latest !PyPI
Activity !PyPI
DeepSource DeepSource

Problem: Switching subscriptions using the Azure CLI involves too much typing.

# Type a lot...
az account list --output table

# Use mouse to select the subscription-id in the console
# Use ctrl-c to copy the text, this might be optional

# Type a lot...
az account set --subscription-id <paste subscription-id>

Solution: I simplified this task with the command-line utility az-switch! The active subscription is bold and green and selected as default argument. Just select the subscription you want to activate.

Install

pip install az-account-switcher

Usage

Usage: az-switch [OPTIONS]

  Show all Azure Subscriptions in current profile using the `az` command-
  line utility. Ask user input for switching to another subscription.

Options:
  -n INTEGER     Switch to this subscription number directly.
  -v, --verbose  Verbose: echo the azure-cli commands.
  -h, --help     Show this message and exit.

Example

example_gif

CHANGELOG

v1.5.0 (05-05-2025):

  • Display tenant name in the subscription list.
  • Show warning when AzureCLI 2.61.0 or newer is detected, no need for this package anymore.
  • Drop support for Python 3.8 and 3.9 since Click 8.2.0 requires Python 3.10+.

v1.4.0 (28-12-2023):

  • Removed az.cli with azure-cli dependencies in favor subprocess call to have a small installation. Assuming az in on your PATH.
  • Drop Python 3.7 support, due to minimal version supported by (dev) dependency commitizen.
  • Switch to poetry for dependency management.

v1.3.0 (25-02-2022):

  • Fixed: issue-8 NotImplementedError by removing deprecated get_azure_cli_credentials in PR-6.
  • Speed-up switching by removing the online interaction pulling the Subscriptions through the Azure-CLI. PR-7
  • Add --verbose flag as an alias to the -v flag.

v1.2.0 (31-05-2021):

  • Support Windows by changing interaction with Azure-CLI using Python package 'az.cli' instead of POpen
  • Drop Python 3.6 support, due to dependent package 'az.cli'
  • Unit tests running on latest versions of Unix, Windows and MacOs
  • Depend on azure-cli instead of azure-cli-core to auto include packagingto fix issue-3

v1.1.0 (04-05-2021):

  • Don't switch when same subscription is selected.
  • Add -v verbose flag to print Azure-CLI sub-commands.
  • Add -h as alias for --help

Thanks to @tqorange for contributing.

v1.0.0 (08-04-2021):

  • Include Python 3.6, not only greater than.
  • Add DeepSource code checker and resolve found issue (related to shell=true)
  • Add aliases for command-line next to az-switch: + az-account-switch + az-account-switcher (the package name)
  • Dump to v1.0.0, since it's working fine for a while and looks better!

v0.0.6 (25-03-2021):

Add support for disabled subscriptions.

Metadata

Release files for az-account-switcher 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for az-account-switcher 1.5.0
File Size Uploaded Provenance Actions
az_account_switcher-1.5.0.tar.gz 5.7 kB Without provenance Details for az_account_switcher-1.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for az-account-switcher 1.5.0
File Interpreter ABI Platform Actions
az_account_switcher-1.5.0-py3-none-any.whl Python 3 none any Details for az_account_switcher-1.5.0-py3-none-any.whl

Total release size: 12.7 kB

Release files / az_account_switcher-1.5.0.tar.gz

Download URL az_account_switcher-1.5.0.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9848075a1af6437974b0948e8473cd7add765168ac76d47791216db0a0e94c85
BLAKE2b-256 checksum
How to use checksums
34659ca6247a8c744db1c1adff179c45ed6dc50b4452d16e1b07541fced87a70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.1 Linux/6.11.0-1014-azure

Release files / az_account_switcher-1.5.0-py3-none-any.whl

Download URL az_account_switcher-1.5.0-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5259359dcd4270fa0435ed15c69ed43ede31111e53b79f3ead8fa7b960d6ed8f
BLAKE2b-256 checksum
How to use checksums
16c7c107475a4c1604ee325c82cfc718d6d49a18bacc4447d2021cfda18c5732
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.1 Linux/6.11.0-1014-azure

Security for az-account-switcher 1.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page