Skip to main content

Downloads PyPI Open Source Code style: black

Azure key vaults

Repository for explaining how to use Azure key vaults in our projects.

Flowdiagram

Index

Usage

This package is designed for easily pulling and creating secrets in Azure key vaults.

pip install this public package

pip install git+ssh://git@github.com/zypp-io/keyvault.git

Secrets to environment

This function sets the keyvault secrets to the runtime environment variables. This function will only work if you have set the required environment variables

from keyvault import secrets_to_environment

secrets_to_environment(keyvault_name="mykeyvault")

Get dotenv secrets

Function for reading the local .env file and capturing the secret_name, secret_value as key value pairs.

from keyvault import get_dotenv_secrets

get_dotenv_secrets(dotenv_file=".env")

Get keyvault secrets

This function can be used to pull secrets from the vault. This function will only work if you have set the required environment variables

from keyvault import get_keyvault_secrets

secrets = get_keyvault_secrets(keyvault_name="mykeyvault")
# Returns a dictionary containing secret_name, secret_value pairs

dotenv to keyvault

This function is designed for making it easy to upload sensitive project secrets to Azure key vault. The function reads the .env file and uploads the names and values to Azure key vault.

from keyvault import dotenv_to_keyvault

dotenv_to_keyvault(keyvault_name="mykeyvault", dotenv_file=".env")
# Uploads your current .env variables to azure key vault

Dict to keyvault

The function lets you upload a dictionary, where the key-value pairs are the secretname-secretvalues in Azure key vault.

from keyvault import dict_to_keyvault

dict_to_keyvault(keyvault_name="mykeyvault", secret_dict={'SECRET_NAME': 'secret value'})

It is also possible to add an expiry date or the content type of the secrets:

from keyvault import dict_to_keyvault
from datetime import datetime, timedelta
expiry_date = datetime.now() + timedelta(days=80)

dict_to_keyvault(
    keyvault_name="mykeyvault",
    secret_dict={'SECRET_NAME': 'secret value'},
    expires_on=expiry_date,
    content_type="text/plain"
)

Delete keyvault secrets

The function lets you delete secrets in the keyvault. Secrets will be deleted with soft_delete enabled.

from keyvault import delete_keyvault_secrets

delete_keyvault_secrets(keyvault_name="mykeyvault", secret_list=["SECRET_NAME"])

mandatory environment variables

There are 3 environment variables that are necessary for authenticating with the azure key vault. These variables always need to be present in the project in order for the secrets to be retrieved.

AZURE_CLIENT_ID=REPLACE-ME
AZURE_CLIENT_SECRET=REPLACE-ME
AZURE_TENANT_ID=REPLACE-ME

Metadata

Release files for keyvault 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for keyvault 1.0.0
File Size Uploaded Provenance Actions
keyvault-1.0.0.tar.gz 5.5 kB Without provenance Details for keyvault-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for keyvault 1.0.0
File Interpreter ABI Platform Actions
keyvault-1.0.0-py3-none-any.whl Python 3 none any Details for keyvault-1.0.0-py3-none-any.whl

Total release size: 11.9 kB

Release files / keyvault-1.0.0.tar.gz

Download URL keyvault-1.0.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1a41c3bc97249007ce5b84d99f88811e601621b6f9aa451fc9f0aadb77792a88
BLAKE2b-256 checksum
How to use checksums
8a0e4037a2f8c233469fbf6526fa653d34a3acb45db8434ca51ff761aed2b168
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / keyvault-1.0.0-py3-none-any.whl

Download URL keyvault-1.0.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba3d8d8db82653741e5230490288146565bbdfd63358bd42b07bcd42d5d5da64
BLAKE2b-256 checksum
How to use checksums
efd43bb2de34039dcd5d52e91fe7d5e371ad7c789c08972b3b0a2e66d2ec8329
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for keyvault 1.0.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page