AZ

azure-keyvault-py

Provides Python SDK access for secure management of Azure Key Vault secrets and keys.

Install

mkdir -p .claude/skills/azure-keyvault-py && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15512" && unzip -o skill.zip -d .claude/skills/azure-keyvault-py && rm skill.zip

Installs to .claude/skills/azure-keyvault-py

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

|
1 chars · catalog descriptionno explicit “when” trigger
Intermediate

Key capabilities

  • Set and retrieve secrets by name
  • Create and manage RSA and EC cryptographic keys
  • Perform cryptographic operations like encrypt, decrypt, sign, and verify
  • Create and manage self-signed certificates
  • List properties of secrets, keys, and certificates
  • Delete and recover secrets and keys

How it works

The skill uses Python SDKs to interact with Azure Key Vault, allowing users to perform operations such as setting, getting, listing, and deleting secrets, keys, and certificates, as well as cryptographic functions.

Inputs & outputs

You give it
Key Vault URL, secret names, key names, certificate names, values, and credentials
You get back
Created, retrieved, or managed secrets, keys, and certificates

When to use azure-keyvault-py

  • Retrieving secrets in python
  • Managing azure key vault keys
  • Setting secret values

About this skill

Azure Key Vault SDK for Python

Secure storage and management for secrets, cryptographic keys, and certificates.

Installation

# Secrets
pip install azure-keyvault-secrets azure-identity

# Keys (cryptographic operations)
pip install azure-keyvault-keys azure-identity

# Certificates
pip install azure-keyvault-certificates azure-identity

# All
pip install azure-keyvault-secrets azure-keyvault-keys azure-keyvault-certificates azure-identity

Environment Variables

AZURE_KEYVAULT_URL=https://<vault-name>.vault.azure.net/

Secrets

SecretClient Setup

from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient

credential = DefaultAzureCredential()
vault_url = "https://<vault-name>.vault.azure.net/"

client = SecretClient(vault_url=vault_url, credential=credential)

Secret Operations

# Set secret
secret = client.set_secret("database-password", "super-secret-value")
print(f"Created: {secret.name}, version: {secret.properties.version}")

# Get secret
secret = client.get_secret("database-password")
print(f"Value: {secret.value}")

# Get specific version
secret = client.get_secret("database-password", version="abc123")

# List secrets (names only, not values)
for secret_properties in client.list_properties_of_secrets():
    print(f"Secret: {secret_properties.name}")

# List versions
for version in client.list_properties_of_secret_versions("database-password"):
    print(f"Version: {version.version}, Created: {version.created_on}")

# Delete secret (soft delete)
poller = client.begin_delete_secret("database-password")
deleted_secret = poller.result()

# Purge (permanent delete, if soft-delete enabled)
client.purge_deleted_secret("database-password")

# Recover deleted secret
client.begin_recover_deleted_secret("database-password").result()

Keys

KeyClient Setup

from azure.identity import DefaultAzureCredential
from azure.keyvault.keys import KeyClient

credential = DefaultAzureCredential()
vault_url = "https://<vault-name>.vault.azure.net/"

client = KeyClient(vault_url=vault_url, credential=credential)

Key Operations

from azure.keyvault.keys import KeyType

# Create RSA key
rsa_key = client.create_rsa_key("rsa-key", size=2048)

# Create EC key
ec_key = client.create_ec_key("ec-key", curve="P-256")

# Get key
key = client.get_key("rsa-key")
print(f"Key type: {key.key_type}")

# List keys
for key_properties in client.list_properties_of_keys():
    print(f"Key: {key_properties.name}")

# Delete key
poller = client.begin_delete_key("rsa-key")
deleted_key = poller.result()

Cryptographic Operations

from azure.keyvault.keys.crypto import CryptographyClient, EncryptionAlgorithm

# Get crypto client for a specific key
crypto_client = CryptographyClient(key, credential=credential)
# Or from key ID
crypto_client = CryptographyClient(
    "https://<vault>.vault.azure.net/keys/<key-name>/<version>",
    credential=credential
)

# Encrypt
plaintext = b"Hello, Key Vault!"
result = crypto_client.encrypt(EncryptionAlgorithm.rsa_oaep, plaintext)
ciphertext = result.ciphertext

# Decrypt
result = crypto_client.decrypt(EncryptionAlgorithm.rsa_oaep, ciphertext)
decrypted = result.plaintext

# Sign
from azure.keyvault.keys.crypto import SignatureAlgorithm
import hashlib

digest = hashlib.sha256(b"data to sign").digest()
result = crypto_client.sign(SignatureAlgorithm.rs256, digest)
signature = result.signature

# Verify
result = crypto_client.verify(SignatureAlgorithm.rs256, digest, signature)
print(f"Valid: {result.is_valid}")

Certificates

CertificateClient Setup

from azure.identity import DefaultAzureCredential
from azure.keyvault.certificates import CertificateClient, CertificatePolicy

credential = DefaultAzureCredential()
vault_url = "https://<vault-name>.vault.azure.net/"

client = CertificateClient(vault_url=vault_url, credential=credential)

Certificate Operations

# Create self-signed certificate
policy = CertificatePolicy.get_default()
poller = client.begin_create_certificate("my-cert", policy=policy)
certificate = poller.result()

# Get certificate
certificate = client.get_certificate("my-cert")
print(f"Thumbprint: {certificate.properties.x509_thumbprint.hex()}")

# Get certificate with private key (as secret)
from azure.keyvault.secrets import SecretClient
secret_client = SecretClient(vault_url=vault_url, credential=credential)
cert_secret = secret_client.get_secret("my-cert")
# cert_secret.value contains PEM or PKCS12

# List certificates
for cert in client.list_properties_of_certificates():
    print(f"Certificate: {cert.name}")

# Delete certificate
poller = client.begin_delete_certificate("my-cert")
deleted = poller.result()

Client Types Table

ClientPackagePurpose
SecretClientazure-keyvault-secretsStore/retrieve secrets
KeyClientazure-keyvault-keysManage cryptographic keys
CryptographyClientazure-keyvault-keysEncrypt/decrypt/sign/verify
CertificateClientazure-keyvault-certificatesManage certificates

Async Clients

from azure.identity.aio import DefaultAzureCredential
from azure.keyvault.secrets.aio import SecretClient

async def get_secret():
    credential = DefaultAzureCredential()
    client = SecretClient(vault_url=vault_url, credential=credential)
    
    async with client:
        secret = await client.get_secret("my-secret")
        print(secret.value)

import asyncio
asyncio.run(get_secret())

Error Handling

from azure.core.exceptions import ResourceNotFoundError, HttpResponseError

try:
    secret = client.get_secret("nonexistent")
except ResourceNotFoundError:
    print("Secret not found")
except HttpResponseError as e:
    if e.status_code == 403:
        print("Access denied - check RBAC permissions")
    raise

Best Practices

  1. Use DefaultAzureCredential for authentication
  2. Use managed identity in Azure-hosted applications
  3. Enable soft-delete for recovery (enabled by default)
  4. Use RBAC over access policies for fine-grained control
  5. Rotate secrets regularly using versioning
  6. Use Key Vault references in App Service/Functions config
  7. Cache secrets appropriately to reduce API calls
  8. Use async clients for high-throughput scenarios

When to Use

This skill is applicable to execute the workflow or actions described in the overview.

When not to use it

  • When not using Python for Azure Key Vault interaction
  • When not managing secrets, keys, or certificates
  • When not interacting with Azure services

Prerequisites

azure-keyvault-secretsazure-keyvault-keysazure-keyvault-certificatesazure-identity

Limitations

  • Requires Python environment
  • Requires Azure Key Vault URL
  • Requires appropriate Azure credentials

How it compares

This skill provides Python-specific methods for Azure Key Vault management, offering programmatic control over secrets, keys, and certificates compared to manual portal operations.

Compared to similar skills

azure-keyvault-py side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
azure-keyvault-py (this skill)05moReviewIntermediate
netalertx-authentication-tokens66moReviewBeginner
auth-implementation-patterns14moNo flagsAdvanced
configuring-oauth2-authorization-flow02moReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry