azure-keyvault-py
Azure Key Vault SDK for Python. Use for secrets, keys, and certificates management with secure storage.
About this skill
This skill empowers AI agents to securely interact with Azure Key Vault, a robust cloud service designed to safeguard cryptographic keys, secrets (such as API keys and database connection strings), and digital certificates. By leveraging the Azure Key Vault SDK for Python, agents can perform critical security operations like creating, retrieving, updating, and deleting these sensitive assets. It is essential for AI applications that require access to secure credentials without embedding them directly in code, significantly enhancing security posture, compliance, and operational best practices.
Best use case
Automating the retrieval or rotation of API keys for external services; securely accessing database credentials for data manipulation tasks; managing SSL/TLS certificates for agent-driven web services or integrations; enabling AI agents to dynamically store and fetch application secrets without hardcoding sensitive information, improving overall security and maintainability.
Azure Key Vault SDK for Python. Use for secrets, keys, and certificates management with secure storage.
The AI agent successfully retrieves, stores, updates, or deletes specified secrets, cryptographic keys, or certificates within a designated Azure Key Vault instance. This ensures secure and compliant access to sensitive data for subsequent agent operations, enhancing the overall security and reliability of the AI application.
Practical example
Example input
```python
# Example of an agent calling the skill to retrieve a secret
agent.run_skill('azure-keyvault-py', operation='get_secret', secret_name='my-api-key')
# Example of an agent calling the skill to set a secret
agent.run_skill('azure-keyvault-py', operation='set_secret', secret_name='db-password', secret_value='superSecureP@ssword123', content_type='password')
```Example output
```json
{
"status": "success",
"operation": "get_secret",
"secret_name": "my-api-key",
"secret_value": "sk_live_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"version": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
}
{
"status": "success",
"operation": "set_secret",
"secret_name": "db-password",
"message": "Secret 'db-password' created or updated successfully.",
"version": "p6o5n4m3l2k1j0i9h8g7f6e5d4c3b2a1"
}
{
"status": "error",
"operation": "get_secret",
"secret_name": "non-existent-secret",
"message": "Secret not found or access denied. Ensure AZURE_KEYVAULT_URL is correct and permissions are granted."
}
```When to use this skill
- When your AI agent needs to access sensitive information (e.g., API keys, database passwords, connection strings) stored securely in Azure Key Vault. When integrating an AI application with other Azure services that require robust credential management. When building applications that must adhere to strict security best practices by externalizing and protecting secrets. When automating the lifecycle management of secrets, such as scheduled rotation or revocation.
When not to use this skill
- For managing non-sensitive configuration data that does not require the high-level security provided by a key vault. If your application or AI agent does not utilize Azure Key Vault for its secret, key, or certificate management needs. For purely local development or testing environments where a simpler (less secure) approach might be temporarily acceptable, although not recommended for production-like scenarios. If you need to manage secrets on a different cloud provider (e.g., AWS Secrets Manager, Google Secret Manager) instead of Azure.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/azure-keyvault-py/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How azure-keyvault-py Compares
| Feature / Agent | azure-keyvault-py | Standard Approach |
|---|---|---|
| Platform Support | Claude | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | medium | N/A |
Frequently Asked Questions
What does this skill do?
Azure Key Vault SDK for Python. Use for secrets, keys, and certificates management with secure storage.
Which AI agents support this skill?
This skill is designed for Claude.
How difficult is it to install?
The installation complexity is rated as medium. You can find the installation instructions above.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Azure Key Vault SDK for Python
Secure storage and management for secrets, cryptographic keys, and certificates.
## Installation
```bash
# 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
```bash
AZURE_KEYVAULT_URL=https://<vault-name>.vault.azure.net/
```
## Secrets
### SecretClient Setup
```python
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
```python
# 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
```python
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
```python
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
```python
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
```python
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
```python
# 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
| Client | Package | Purpose |
|--------|---------|---------|
| `SecretClient` | `azure-keyvault-secrets` | Store/retrieve secrets |
| `KeyClient` | `azure-keyvault-keys` | Manage cryptographic keys |
| `CryptographyClient` | `azure-keyvault-keys` | Encrypt/decrypt/sign/verify |
| `CertificateClient` | `azure-keyvault-certificates` | Manage certificates |
## Async Clients
```python
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
```python
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.Related Skills
azure-security-keyvault-keys-java
Azure Key Vault Keys Java SDK for cryptographic key management. Use when creating, managing, or using RSA/EC keys, performing encrypt/decrypt/sign/verify operations, or working with HSM-backed keys.
azure-security-keyvault-keys-dotnet
Azure Key Vault Keys SDK for .NET. Client library for managing cryptographic keys in Azure Key Vault and Managed HSM. Use for key creation, rotation, encryption, decryption, signing, and verification.
mtls-configuration
Configure mutual TLS (mTLS) for zero-trust service-to-service communication. Use when implementing zero-trust networking, certificate management, or securing internal service communication.
mobile-security-coder
Expert in secure mobile coding practices specializing in input validation, WebView security, and mobile-specific security patterns.
malware-analyst
Expert malware analyst specializing in defensive malware research, threat intelligence, and incident response. Masters sandbox analysis, behavioral analysis, and malware family identification.
linux-privilege-escalation
Execute systematic privilege escalation assessments on Linux systems to identify and exploit misconfigurations, vulnerable services, and security weaknesses that allow elevation from low-privilege user access to root-level control.
laravel-security-audit
Security auditor for Laravel applications. Analyzes code for vulnerabilities, misconfigurations, and insecure practices using OWASP standards and Laravel security best practices.
frontend-security-coder
Expert in secure frontend coding practices specializing in XSS prevention, output sanitization, and client-side security patterns.
frontend-mobile-security-xss-scan
You are a frontend security specialist focusing on Cross-Site Scripting (XSS) vulnerability detection and prevention. Analyze React, Vue, Angular, and vanilla JavaScript code to identify injection poi
differential-review
Security-focused code review for PRs, commits, and diffs.
dependency-management-deps-audit
You are a dependency security expert specializing in vulnerability scanning, license compliance, and supply chain security. Analyze project dependencies for known vulnerabilities, licensing issues, outdated packages, and provide actionable remediation strategies.
cloud-penetration-testing
Conduct comprehensive security assessments of cloud infrastructure across Microsoft Azure, Amazon Web Services (AWS), and Google Cloud Platform (GCP).