pydantic-settings-azure-app-configuration
Introduction
https://learn.microsoft.com/en-us/azure/azure-app-configuration/overview
Installation
uv add pydantic-settings-azure-app-configuration
Usage
By default, it loads all the values from Azure App Configuration, but you can assign a prefix to your application (e.g. my_api__) and load only the values for it using the select_key method. You can also use the trim_key_prefix method to remove the prefix from the value names.
Furthermore, if some value references a secret stored in Azure Key Vault, you can use the configure_key_vault method to retrieve it.
If you use Entra ID authentication, you can use the role App Configuration Data Reader to access the configurations and Key Vault Secrets User to access the secrets.
To nest models you have to define a env_nested_delimiter (e.g. __), either in the source constructor or in the model_config class.
The configuration of this settings source is almost idental to the the provided by ASP.NET Core, in case you want to read the official documentation to inform you about more complex uses, best practices, etc.
import os
from azure.identity import DefaultAzureCredential
from pydantic import BaseModel
from pydantic_settings import BaseSettings, PydanticBaseSettingsSource
from pydantic_settings_azure_app_configuration.source import (
AzureAppConfigurationSettingsSource,
)
class SqlServer(BaseModel):
password: str
host: str
class AzureKeyVaultSettings(BaseSettings):
logging_level: str
sql_server: SqlServer
@classmethod
def settings_customise_sources(
cls,
settings_cls: type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> tuple[PydanticBaseSettingsSource, ...]:
azure_credential = DefaultAzureCredential()
azure_app_configuration = AzureAppConfigurationSettingsSource(
settings_cls,
lambda app_configuration_options: app_configuration_options.connect_with_url(
os.environ["AZURE_APP_CONFIGURATION_URL"], azure_credential
)
.select_key("my_api__*")
.trim_key_prefix("my_api__")
.configure_key_vault(
lambda key_vault_options: key_vault_options.set_credential(
azure_credential
)
),
env_nested_delimiter="__",
)
return (
init_settings,
env_settings,
dotenv_settings,
file_secret_settings,
azure_app_configuration,
)
Metadata
Release files for pydantic-settings-azure-app-configuration 1.1.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 | Actions |
|---|---|---|---|---|
| pydantic_settings_azure_app_configuration-1.1.0.tar.gz | 3.7 kB | Without provenance | Details for pydantic_settings_azure_app_configuration-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydantic_settings_azure_app_configuration-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for pydantic_settings_azure_app_configuration-1.1.0-py3-none-any.whl |
Total release size: 8.5 kB
Release files / pydantic_settings_azure_app_configuration-1.1.0.tar.gz
| Download URL | pydantic_settings_azure_app_configuration-1.1.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf5450c01cfb2b7a5e204e425c86b15b4eac6e8c38f16d9d0c7b614eda7ef1ee
|
|
BLAKE2b-256 checksum How to use checksums |
9578514e5dae72a5c5f45ef0b8c455651e87f9ac3c7d6a8841f515aa91adf5f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.15
|
Release files / pydantic_settings_azure_app_configuration-1.1.0-py3-none-any.whl
| Download URL | pydantic_settings_azure_app_configuration-1.1.0-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1cc3b7c8e661eb8cdbd85eee6eda036152d83c808d6cb7be5f1224fc403948fa
|
|
BLAKE2b-256 checksum How to use checksums |
dc2a81d5f3af5cca2193faa528af7daf21f410174e09c6bf474b4f9b5838b515
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.15
|
Security for pydantic-settings-azure-app-configuration 1.1.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.