Skip to main content

Python dotenv adapter that loads dotenv key value pairs from Azure Developer CLI (azd)

Project description

dotenv-azd

PyPI - Version PyPI - Status PyPI - Python Version PyPI - Downloads

This library provides a Python python-dotenv wrapper function that loads dotenv key value pairs from the currently selected Azure Developer CLI (azd) environment.

Installation

pip install dotenv-azd

Usage

Create a new AZD env if you don't have one yet and set an initial variable value:

azd init MY_AZD_ENV
azd env set VAR1 OVERRIDE

In your Python code:

from dotenv_azd import load_azd_env
from os import getenv, environ

environ['VAR1'] = 'INITIAL'

load_azd_env()

print(getenv('AZURE_ENV_NAME')) # prints 'MY_AZD_ENV', loaded from azd env

print(getenv('VAR1')) # prints 'INITIAL', was already in Python env

Override mode

You can also override variables in Python env:

load_azd_env(override=True)
print(getenv('VAR1')) # prints 'OVERRIDE', loaded from azd env, overriding Python env

Quiet mode

If you want to ignore errors when azd is not initialized or no azd environment is active, you can use the quiet parameter. This is useful when integrating with azd while avoiding dependency on it.

load_azd_env(quiet=True)

License

dotenv-azd is distributed under the terms of the MIT license.

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

dotenv_azd-0.2.0rc1.tar.gz (8.4 kB view hashes)

Uploaded Source

Built Distribution

dotenv_azd-0.2.0rc1-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

Supported by

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