Skip to main content

azpass

Command line tool to manage the secrets of the Azure Key Vaults.

The tool uses the Azure Python SDK and the usual Azure authentication (az login, service principal through the AZURE_* environment variables, managed identity). Every operation has an equivalent az command, which --dry-run prints.

Install

python3 -m pip install --user azpass

Usage

azpass                                 # List the key vaults
azpass my-vault                        # List the secrets of a key vault
azpass my-vault my-secret              # Print the value of a secret
azpass my-vault --set my-secret        # Set a secret, the value being asked
azpass my-vault --rm my-secret         # Delete a secret

The value of a secret is never given as an argument: an argument would be visible in the shell history and in the process list. On a terminal it is asked without echo, and the end of line validates it:

$ azpass my-vault --set my-secret
azpass: value of the secret 'my-secret' in 'my-vault': ********
https://my-vault.vault.azure.net/secrets/my-secret/89a1c00898fc...

It can also be piped, which is the only way to set a value spanning many lines:

echo hunter2 | azpass my-vault --set my-secret
azpass my-vault --set my-cert < my-cert.pem

One trailing end of line is dropped, so a value ending with a real end of line has to be piped without it, with printf for example.

--set creates a new version of the secret, the previous ones remaining available until the deletion of the secret. It prints the identifier of the new version, azpass my-vault my-secret gives the value back.

Options

Option Description
--json Print the full JSON document, like the az CLI does
--dry-run Print the equivalent az command, without calling Azure
--subscription The subscription to search into
--vault-url The URL of the key vault, for the sovereign clouds
--no-cache Ignore and do not update what was remembered of Azure

The subscription is taken from --subscription, then from the AZURE_SUBSCRIPTION_ID environment variable, then from the last one used, then from the only accessible subscription. When several subscriptions are accessible and none was ever used, the tool fails and lists them.

The key vaults are listed within a single subscription, like az keyvault list does. The deletion of a secret is a soft delete, purge the vault to remove it for good.

Cache

Asking Azure which subscriptions are accessible, and where a key vault lives, costs one or two round trips. The tool therefore remembers:

  • the last subscription used, and the URL of the key vaults already resolved, in $XDG_CONFIG_HOME/azpass/state.json, which holds no secret at all;
  • the bearer tokens, in $XDG_CACHE_HOME/azpass/tokens.json.

Both files are created with the permissions 0600, for the owner only. The tokens are written in clear text and expire on their own, generally within an hour: do not use this cache on a machine you do not own, --no-cache disables it for one command and removing the two files resets it completely.

When Azure refuses a request because of a stale URL or token, with a status 401, 403 or 404, the remembered answers are dropped and the command is tried once again against Azure.

While a command is running, azpass: contacting Azure is shown on the terminal and erased afterwards. Nothing is written when the standard error is a pipe, and the message of a value prompt never reaches the standard output.

JSON output

The JSON documents are the ones of the az CLI, --dry-run --json gives the command that produces them:

$ azpass my-vault my-secret --dry-run --json
az keyvault secret show --vault-name my-vault --name my-secret --output json

The list of the secrets never contains the values, Azure does not return them for that operation.

Dry run

Nothing is sent to Azure during a dry run, no credential is even required, so it works without being logged in, and no cache file is read or written. As the subscription is not resolved, it is replaced by the <subscription> placeholder in the listed key vaults command unless --subscription or AZURE_SUBSCRIPTION_ID gives it:

$ azpass --dry-run
az keyvault list \
  --query '[].{name:name,rg:resourceGroup,url:properties.vaultUri}' \
  --output tsv --subscription '<subscription>'

The value of a secret is never printed by a dry run, it is replaced by <hidden>.

Authentication

DefaultAzureCredential of the azure-identity package is used, so any of the classical methods works. The simplest one is:

az login

The account needs the read permission on the key vaults of the subscription (Key Vault Reader or Owner), and on the secrets the Key Vault Secrets User role to read them, Key Vault Secrets Officer to set or delete them, unless the vault uses the legacy access policies.

Run tests and prospector

python3 -m pip install --user --upgrade poetry
poetry install
poetry run pytest
poetry run prospector --output=pylint azpass

Create new release

git tag <version>
git push origin <version>

Contributing

Install the pre-commit hooks:

pip install pre-commit
pre-commit install --allow-missing-config

Metadata

Release files for azpass 0.1.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 azpass 0.1.0
File Size Uploaded Provenance Actions
azpass-0.1.0.tar.gz 15.9 kB Without provenance Details for azpass-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for azpass 0.1.0
File Interpreter ABI Platform Actions
azpass-0.1.0-py3-none-any.whl Python 3 none any Details for azpass-0.1.0-py3-none-any.whl

Total release size: 31.5 kB

Release files / azpass-0.1.0.tar.gz

Download URL azpass-0.1.0.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3a94e53807be03bbac9b13e1cc7c98dfae85c5e3288f4bcf9118490c1426c672
BLAKE2b-256 checksum
How to use checksums
e6482f4ad5808376a0a4fcde94bb31bca7a9758da078b4a158cb4d93e7cb4480
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.13.18

Release files / azpass-0.1.0-py3-none-any.whl

Download URL azpass-0.1.0-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8827e32e26a8c2cca2c8fe25d7145a0e18eb0f04cc5789aed82de184b5efa669
BLAKE2b-256 checksum
How to use checksums
5e83896e9a82744f340a756e3ec8d6851db7b1717d13185fd3b4d7c31ebdb6ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.13.18

Security for azpass 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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