dotenv-azd
dotenv-azd allows seamless integration of Azure Developer CLI (azd) environment variables into your Python applications without the need to manually export them to an .env file. This can greatly enhance productivity and reduce potential errors, allowing for a smoother development experience.
It leverages the azd CLI and the python-dotenv library.
Why dotenv-azd
Integrating azd environment variables directly into your Python applications can streamline your development process. By avoiding the manual export to .env files, you can reduce overhead and minimize mistakes. This is especially useful when switching between different azd environments.
Installation
pip install dotenv-azd
Usage
Basic 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)
Alternatives
The traditional approach to integrate azd environment variables is to export them to a .env file and load that file:
azd env get-values > .env
This approach can create variable quoting issues and might lead to stale variables when switching between environments using azd select.
Contributing
Make a PR to the repo. Run hatch fmt --check to make sure the code is correctly linted.
License
dotenv-azd is distributed under the terms of the MIT license.
Metadata
Release files for dotenv-azd 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dotenv_azd-0.3.0.tar.gz | 9.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dotenv_azd-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.4 kB
Release files / dotenv_azd-0.3.0.tar.gz
| Download URL | dotenv_azd-0.3.0.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6905c9b7f57e795d66eccb3951814fc62c53fa1d0b22574ee1f726565e543026
|
|
BLAKE2b-256 checksum How to use checksums |
619561a3b01f6fccd2b3d4df619ecb91e986f88eedf18cf6ab4799cf21cf7025
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.28.1
|
Release files / dotenv_azd-0.3.0-py3-none-any.whl
| Download URL | dotenv_azd-0.3.0-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
db57c4cba883662f23a64d86bc3dd1bdf91bcbf13f6452d3db4c156c203657a4
|
|
BLAKE2b-256 checksum How to use checksums |
c1f635a119a3dcfc8995542fee35c83e800a144890337c9a8377d22a2052fa1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.28.1
|
Security for dotenv-azd 0.3.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.