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.1.tar.gz (4.2 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.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for python_kv_dotenv-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8b3bb7c3e579c82a128fe32a9c3e5a04d38eb6ba019f415e5feb65642d7de85b
MD5 65ae7c8c0a0fd376e505803401033296
BLAKE2b-256 0d2857b8fac3ee061eb8c85c80c401ddfd2bef6f5233cca94372b490cfe5de8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_kv_dotenv-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 26bd5e746456d657dcc74f25a603da5887ba9ed7b971f8da56461ff0691a7b81
MD5 04f37914f4024f9439efc6e2f4d497d6
BLAKE2b-256 68803bed047eddcc123717921ab5205224eb9991298c80d697b48ef65110282b

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