Skip to main content

A Python component scaffold for configuration utilities.

Project description

appfx.configuration

CI Publish PyPI Python versions License: MIT

appfx.configuration is a lightweight Python configuration utility for loading application settings from local .env files and Azure App Configuration.

The package is designed for applications that want predictable configuration loading, local-development overrides, and optional population of os.environ for libraries that read configuration from environment variables.

Features

  • Load .env values into os.environ.
  • Read Azure App Configuration values using DefaultAzureCredential.
  • Return merged configuration as dict[str, str].
  • Optionally write merged Azure and .env settings into os.environ.
  • Preserve existing process environment values by default.
  • Include a py.typed marker for typed consumers.

Package and import names

Purpose Name
PyPI distribution appfx-configuration
Python package appfx.configuration
.env helpers appfx.configuration.env
Azure App Configuration helpers appfx.configuration.azure

Installation

Install from PyPI after the package is published:

python -m pip install appfx-configuration

For local development, install the package in editable mode with development tools:

python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

Configure Azure App Configuration

Copy the example environment file and set your Azure App Configuration endpoint:

Copy-Item .env.example .env

The required endpoint variable name is AZURE_APPCONFIG_ENDPOINT:

AZURE_APPCONFIG_ENDPOINT=https://<your-app-configuration-name>.azconfig.io

The Azure loader reads AZURE_APPCONFIG_ENDPOINT from .env or os.environ before connecting to Azure App Configuration. The local .env file is ignored by Git so local endpoints and secrets are not committed.

Authentication is handled by DefaultAzureCredential. Before loading Azure App Configuration values, authenticate with a supported Azure Identity mechanism such as Azure CLI sign-in, managed identity, or environment-based credentials.

Usage

Load .env values only

Use appfx.configuration.env when you only need local .env values loaded into os.environ.

from appfx.configuration.env import load_environment_variables

local_settings = load_environment_variables()

Read Azure App Configuration as a dictionary

Use load_app_configuration_settings() when you want a merged dictionary without writing Azure-only values into os.environ.

from appfx.configuration.azure import load_app_configuration_settings

settings = load_app_configuration_settings()
value = settings["MY_SETTING"]

Load Azure App Configuration into os.environ

Use load_app_configuration_environment() when downstream libraries expect configuration in environment variables.

from appfx.configuration.azure import load_app_configuration_environment

settings = load_app_configuration_environment()

Pass override=True to replace existing process environment values with loaded configuration values:

settings = load_app_configuration_environment(override=True)

Loading behavior

The loaders apply configuration in this order:

  1. Azure App Configuration values are read first.
  2. Values from .env override Azure values with the same key.
  3. Existing process environment values may override matching keys from .env.

By default, existing process environment values win. Unrelated process environment variables are not included in returned settings dictionaries.

If AZURE_APPCONFIG_ENDPOINT is missing or blank, Azure helpers raise AzureAppConfigurationEndpointError with a setup-focused error message.

Public API

appfx.configuration.env

API Description
load_environment_variables(env_file=".env", override=False) Loads variables from a .env file into os.environ and returns the effective values for keys declared in that file.

appfx.configuration.azure

API Description
load_app_configuration_settings(...) Loads .env, reads Azure App Configuration, and returns merged settings as dict[str, str].
load_app_configuration_environment(..., override=False) Loads merged settings and writes them into os.environ.
create_default_credential() Creates the default Azure credential chain.
AzureAppConfigurationEndpointError Raised when AZURE_APPCONFIG_ENDPOINT is missing or blank.
AZURE_APPCONFIG_ENDPOINT_ENV_VAR Constant for the required endpoint environment variable name.

Development

Run the local validation suite:

python -m pytest
python -m pytest --cov
python -m ruff check .
python -m ruff format --check .
python -m mypy
python -m build
python -m twine check dist/*

Publishing

This project is configured for PyPI Trusted Publishing through GitHub Actions. Publishing does not require a PyPI API token in GitHub secrets or local terminals.

Before the first publish, create a PyPI pending publisher for appfx-configuration with these values:

PyPI Trusted Publisher field Value
PyPI project name appfx-configuration
Owner Dongbumlee
Repository name appfx-configuration
Workflow name publish.yml
Environment name pypi

To publish a release, create and publish a GitHub release, or run the Publish workflow manually from GitHub Actions after the pending publisher is configured.

Project layout

.
├── .github/workflows/     # CI and PyPI publish workflows
├── docs/                  # Package documentation
├── examples/              # Usage examples
├── scripts/               # Maintenance/release script notes
├── src/appfx/configuration/
│   ├── azure/             # Azure App Configuration helpers
│   ├── env.py             # .env environment loader
│   └── py.typed           # Typing marker
└── tests/                 # Automated tests

License

This project is licensed under the MIT License. See LICENSE for details.

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

appfx_configuration-0.1.1.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

appfx_configuration-0.1.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: appfx_configuration-0.1.1.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for appfx_configuration-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3644a243f8d43ed3241701fedcea3018df7a8daf35cbd14647845c13e40482d5
MD5 d8080d3524b1e1afdae220f7ce51a224
BLAKE2b-256 7292c4253c620ecb01dd7d36772ef46c75828656e5f6c750c8d69d1fa49b4014

See more details on using hashes here.

Provenance

The following attestation bundles were made for appfx_configuration-0.1.1.tar.gz:

Publisher: publish.yml on Dongbumlee/appfx-configuration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for appfx_configuration-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 75f14180781070822ec8c5cc4ed271dab6777d37385e8e61c078d6c259b155c1
MD5 8d14e20f78f22a4db4b409b19be7f8c0
BLAKE2b-256 da30cb84056ac92c646213f074a91ea8937e126c848f527693f665946a9a17a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for appfx_configuration-0.1.1-py3-none-any.whl:

Publisher: publish.yml on Dongbumlee/appfx-configuration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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