Skip to main content

Azure Key Vault source for essentials-configuration

Project description

Build pypi versions codecov license

essentials-configuration-keyvault

Azure Key Vault source for essentials-configuration.

pip install essentials-configuration-keyvault

essentials-configuration provides a way to handle configuration roots composed of different layers, such as configuration files and environmental variables. Layers are applied in order and can override each others' values, enabling different scenarios like configuration by environment (e.g. DEV, TEST, PROD) and system instance.

essentials-configuration-keyvault provides a solution to add secrets stored in Azure Key Vault into configuration objects.

Example:

from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
from configuration.common import ConfigurationBuilder
from configuration.keyvault import KeyVaultSource

key_vault_name = "example-keyvault-name"

secrets_client = SecretClient(
    vault_url=f"https://{key_vault_name}.vault.azure.net",
    credential=DefaultAzureCredential(),
)

builder = ConfigurationBuilder(KeyVaultSource(secrets_client))

# when the configuration object is built, secrets are fetched from
# the linked key vault and put into the configuration object (e.g.
# database connection strings, API keys for SendGrid, etc.)
config = builder.build()

Refer to the official Key Vault documentation for more information about its Python client library..

How to run the tests using a real Key Vault

The provided tests can either use a mocked SecretClient, or use a real Key Vault. To use a real Key Vault service:

  1. create a Key Vault (ref.)
  2. sign-in using any way supported by azure.identity.DefaultAzureCredential (e.g. VS Code or az login)
  3. run the tests with the following command:
KEYVAULT_NAME="<YOUR_KEYVAULT_NAME>" pytest -s

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

Built Distribution

File details

Details for the file essentials-configuration-keyvault-0.0.2.tar.gz.

File metadata

  • Download URL: essentials-configuration-keyvault-0.0.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for essentials-configuration-keyvault-0.0.2.tar.gz
Algorithm Hash digest
SHA256 85751ea0310ecd354208df942072e19610302f1c44c7cd46e6afaddb373cb4a1
MD5 0f09e3c32cc0a1b0933143813e226bc0
BLAKE2b-256 51bd2ef59dc5a4c4dd3eabfe5002cedeb1b77a7ac0831a8b596543faa4a8f20b

See more details on using hashes here.

File details

Details for the file essentials_configuration_keyvault-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: essentials_configuration_keyvault-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for essentials_configuration_keyvault-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b39bdca7094e4f3dbd7ca787ae17addd7354a0055c3cbee13c5fd9f421e7b308
MD5 7d6adf7853f788911b7c0eb002ff60c3
BLAKE2b-256 0b587ae65cd84a9faa61402eb4e1d1567bb76437ec0a5f8c5280e376771aad08

See more details on using hashes here.

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