Skip to main content

Load .env files and resolve Azure Key Vault secret URLs.

Project description

python-kv-dotenv

python-kv-dotenv is a small wrapper around python-dotenv that resolves Azure Key Vault secret references while loading .env files.

It keeps python-dotenv file discovery and variable interpolation behavior, and adds support for wrapped Key Vault URLs in env values.

Install

pip install python-kv-dotenv

Supported kv: format

kv:https://<vault>.vault.azure.net/secrets/<secret-name>
kv:https://<vault>.vault.azure.net/secrets/<secret-name>/<secret-version>

Example

.env

MAXIMO_CONNSTRING=kv:https://example.vault.azure.net/secrets/maximo-prod-connstring
ENV=dev

Python:

import os

from python_kv_dotenv import load_kv_dotenv

load_kv_dotenv()

print(os.environ["ENV"])
print("MAXIMO_CONNSTRING" in os.environ)

Authentication

Secret resolution uses azure.identity.DefaultAzureCredential by default.

You can also pass a custom Azure credential:

from azure.identity import DefaultAzureCredential

from python_kv_dotenv import load_kv_dotenv

load_kv_dotenv(credential=DefaultAzureCredential())

Notes

  • Non-kv: values are loaded like normal python-dotenv values.
  • kv: references are resolved before later ${VAR} interpolation uses them.
  • Secret lookup failures are fail-fast and raise the underlying Azure error.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_kv_dotenv-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_kv_dotenv-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file python_kv_dotenv-0.1.0.tar.gz.

File metadata

  • Download URL: python_kv_dotenv-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.3

File hashes

Hashes for python_kv_dotenv-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b27503379877b321082aa006d4a7c22128dda77751f2500bd98e7e1b2c8dc828
MD5 c863e1efaab0bae3e988d929670e0b5e
BLAKE2b-256 a155af97317f493bdba4e9bb3322a28931f9f892a1c0311c628abc56e587cd1e

See more details on using hashes here.

File details

Details for the file python_kv_dotenv-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_kv_dotenv-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ee365e23ee92f9ce2a64fe8fd602f580cd5d35b8d47aa53d85b6100da003b60
MD5 9d0392f1968f5d082f453dffed55fd7f
BLAKE2b-256 70e996298143e8ec115eb74267dcb69961cbc1e7acd9d90dcc9ea845fbdf6428

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page