Registry / azure / azure-keyvault-securitydomain

azure-keyvault-securitydomain

JSON →
library1.0.0b3pypypi✓ verified 22d ago

The Azure Key Vault Security Domain client library for Python allows developers to securely manage the security domain of an Azure Key Vault Managed HSM. This includes operations to download and restore a Managed HSM's security domain, which is crucial for establishing ownership, setting cryptographic boundaries, and enabling disaster recovery. The library is currently in a beta release, version `1.0.0b1`, as part of the broader Azure SDK for Python, which follows a regular release cadence with preview versions often preceding stable releases.

pip install azure-keyvault-securitydomain azure-identity
INSTALL
IMPORT
SIG · AZURE-KEYVAULT-SEC
A
azure-keyvault-securitydomain
azurepythonv1.0.0b3
Install
3.7s avg
Import
418ms
Disk
42MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.0b3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.434s · 43.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.7s · import 0.402s · 44MB
42MB installed
● package 42MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SecurityDomainClient
from azure.keyvault.securitydomain import SecurityDomainClient
DefaultAzureCredential
from azure.identity import DefaultAzureCredential
SecurityDomainJsonWebKey
from azure.keyvault.securitydomain.models import SecurityDomainJsonWebKey
Used for representing JWK for security domain operations.
SecurityDomain
from azure.keyvault.securitydomain.models import SecurityDomain
Model for a security domain object, often returned by download operations.
SecurityDomainOperationStatus
from azure.keyvault.securitydomain.models import SecurityDomainOperationStatus
Model for the status of a security domain operation.

This quickstart demonstrates how to instantiate the `SecurityDomainClient` using `DefaultAzureCredential` for authentication. It highlights the prerequisites for performing actual security domain operations like downloading, which include an Azure Key Vault Managed HSM and specific key management for encryption.

import os from azure.identity import DefaultAzureCredential from azure.keyvault.securitydomain import SecurityDomainClient # Set your Managed HSM URL as an environment variable # Example: 'https://my-managed-hsm.managedhsm.azure.net/' VAULT_URL = os.environ.get("AZURE_MANAGEDHSM_URL", "<your-managed-hsm-url>") # --- Prerequisites for actual operations --- # For actual download/upload, you would need: # 1. An active Azure subscription. # 2. An existing Azure Key Vault Managed HSM (not a standard Key Vault). # 3. RSA key pairs (public keys for 'sd_wrapping_keys') and a specified quorum. # 4. Proper RBAC permissions for your identity to perform security domain operations. # (e.g., 'Managed HSM Security Domain Contributor' role). if VAULT_URL == '<your-managed-hsm-url>': print("Please set the AZURE_MANAGEDHSM_URL environment variable or replace the placeholder.") exit(1) try: # Authenticate using DefaultAzureCredential # This will try various methods: environment variables, managed identity, Azure CLI, etc. credential = DefaultAzureCredential() # Create a SecurityDomainClient client = SecurityDomainClient(vault_url=VAULT_URL, credential=credential) print(f"Successfully created SecurityDomainClient for: {VAULT_URL}") # --- Example: (Conceptual) Download a security domain --- # This operation requires 'certificate_info' (public keys) and 'quorum'. # It's a long-running operation, so 'begin_download' returns a poller. # For a real scenario, 'certs_object' would be a list of SecurityDomainJsonWebKey objects # and 'quorum' would be an integer. # Example: certs_object = [SecurityDomainJsonWebKey(...), ...] # quorum = 2 # poller = client.begin_download(certificate_info=certs_object, quorum=quorum) # security_domain = poller.result() # print("Security Domain downloaded.") # For demonstration, we'll just show client creation and a dummy print. print("Client created. Actual security domain operations require a Managed HSM and specific certificate setup.") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
breakingAs a beta library (`1.0.0b1`), `azure-keyvault-securitydomain` is subject to breaking changes in future releases before reaching general availability. APIs, models, and behaviors may change without backward compatibility guarantees.
fix
Monitor release notes for subsequent versions and update code as necessary. Test thoroughly when upgrading.
affects: All beta versions (e.g., 1.0.0b1)
gotchaThis library is specifically designed for Azure Key Vault Managed HSMs, not standard Azure Key Vaults. Attempting to use it with a standard Key Vault will result in errors.
fix
Ensure you are interacting with an Azure Key Vault Managed HSM resource. Create one if necessary via Azure CLI or Azure Portal.
affects: All versions
gotchaAuthentication with Azure services, including Managed HSM, requires proper configuration for `DefaultAzureCredential`. In development, this often means logging in via Azure CLI or setting environment variables (`AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_TENANT_ID`). In production, Managed Identities are recommended.
fix
Refer to the `azure-identity` documentation for setting up appropriate credentials for your environment. Ensure your identity has the necessary RBAC roles (e.g., 'Managed HSM Security Domain Contributor') on the Managed HSM.
affects: All versions
gotchaSecurity domain operations (e.g., download, upload) are long-running and return `LROPoller` objects. You must call `.result()` on the poller to wait for the operation to complete and retrieve the final result or status.
fix
Always call `.result()` on the `LROPoller` returned by `begin_download`, `begin_upload`, etc., to get the operation's outcome. Example: `security_domain = client.begin_download(...).result()`.
affects: All versions
breakingAzure Key Vault is shifting to Azure Role-Based Access Control (RBAC) as the default access control model, deprecating older vault access policies. While this isn't a direct API change in `azure-keyvault-securitydomain`, it critically impacts how permissions are granted to your application's identity accessing the Managed HSM. Older API versions will be retired by February 27, 2027.
fix
Migrate access control for your Managed HSMs to Azure RBAC and ensure your deployment scripts use API version `2026-02-01` or later for Key Vault/Managed HSM creation and management. Review and assign appropriate RBAC roles.
affects: Impacts all Key Vault users; specific API version `2026-02-01` and later become default.
gotchaActual `begin_download` and `begin_upload` operations require a collection of RSA public keys (certificates) and a 'quorum' to encrypt/decrypt the security domain using Shamir's Secret Sharing Algorithm. Generating and managing these keys securely is a complex prerequisite.
fix
Generate the required number of RSA key pairs (typically 3-10) and manage their private keys securely offline. Extract the public keys (e.g., from self-signed certificates) and pass them to the `certificate_info` parameter, along with the `quorum` (minimum number of private keys needed for decryption).
affects: All versions
gotchaTyping issues have been reported for `azure-keyvault-securitydomain` with specific `pyright` versions (e.g., 1.1.408). This could lead to static analysis failures or runtime issues in environments with strict type checking.
fix
Monitor for library updates that address typing fixes. If encountering issues, temporarily adjust `pyright` configuration or type-checking strictness, or contribute fixes to the Azure SDK for Python.
affects: 1.0.0b1 (and potentially future beta versions)
Upgrade
Version history
1.0.0b3latest on PyPI · released Aug 26, 2026
Audit
Dependencies
pythonrequiredRequired for running the library.
azure-identityrequiredRequired for authenticating to Azure services, including Azure Key Vault Managed HSM.
Agent activity
45 hits · last 30 days
node
36
Amazon
1
OpenAI (training)
1
Resources