azure-keyvault – skill DevOps & Hạ tầng cho agent AI
Quản lý secret và chứng chỉ trong Azure Key Vault. Cấu hình access policy, tích hợp với dịch vụ Azure và triển khai quản lý secret an toàn. Dùng khi quản lý secret trong môi trường Azure.
Cài skill azure-keyvault bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-keyvault-45b89.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /azure-keyvault – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-keyvault-45b89.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $azure-keyvault – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-keyvault-45b89.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /azure-keyvault – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-keyvault-45b89.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /azure-keyvault – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Azure Key Vault
Securely store and manage secrets, keys, and certificates in Azure.
Prerequisites
- Azure subscription with appropriate permissions
- Azure CLI installed (
azcommand) - Control-plane vault-management permission and separate least-privilege data-plane roles; assigning roles additionally needs authorized role-assignment permission
- Managed identity configured for application access
- Understanding of Azure RBAC vs. Key Vault access policies
Vault Creation and Configuration
# Create a resource group
az group create --name rg-secrets --location eastus
# Create Key Vault with RBAC authorization (recommended)
az keyvault create \
--name myapp-vault-prod \
--resource-group rg-secrets \
--location eastus \
--enable-rbac-authorization true \
--enable-soft-delete true \
--retention-days 90 \
--enable-purge-protection true \
--sku premium # Use premium for HSM-backed keys
# Legacy policy mode must be explicitly selected; modern new vaults default to RBAC.
# Create Key Vault with access policies (legacy)
az keyvault create \
--name myapp-vault-dev \
--enable-rbac-authorization false \
--resource-group rg-secrets \
--location eastus \
--enable-soft-delete true \
--retention-days 30
# Disable public access only AFTER creating/approving a private endpoint and DNS path;
# this update does not create an endpoint and otherwise locks out clients.
az keyvault update \
--name myapp-vault-prod \
--resource-group rg-secrets \
--public-network-access Disabled
# Enable diagnostics logging
az monitor diagnostic-settings create \
--name kv-diagnostics \
--resource "/subscriptions/{sub}/resourceGroups/rg-secrets/providers/Microsoft.KeyVault/vaults/myapp-vault-prod" \
--workspace "/subscriptions/{sub}/resourceGroups/rg-monitor/providers/Microsoft.OperationalInsights/workspaces/security-logs" \
--logs '[{"category":"AuditEvent","enabled":true,"retentionPolicy":{"enabled":true,"days":365}}]'Secret Management
Create referenced secret files via protected local input with mode0600, never commit them or expose values in argv/logs. Secret set responses include values unless output is suppressed. Confirm subscription/vault/object IDs and recovery before mutation/purge; purge protection cannot be disabled after enabling. Read-only show also exposes secret values, so use only for a concrete authorized need. Expiry metadata does not rotate downstream application credentials. Public-access disablement is not private-endpoint provisioning.
# Set a secret
az keyvault secret set \
--vault-name myapp-vault-prod \
--name db-password \
--file db-password.txt --output none \
--content-type "text/plain" \
--tags Environment=production Team=platform
# Set a multi-line secret (JSON credentials)
az keyvault secret set \
--vault-name myapp-vault-prod \
--name db-credentials \
--file db-credentials.json --output none
# Get secret value
az keyvault secret show \
--vault-name myapp-vault-prod \
--name db-password \
--query value -o tsv
# Get specific version
az keyvault secret show \
--vault-name myapp-vault-prod \
--name db-password \
--version abc123def456
# List all secrets
az keyvault secret list --vault-name myapp-vault-prod -o table
# List secret versions
az keyvault secret list-versions \
--vault-name myapp-vault-prod \
--name db-password -o table
# Set expiration date
az keyvault secret set-attributes \
--vault-name myapp-vault-prod \
--name api-key \
--expires "2026-01-01T00:00:00Z"
# Disable a secret (without deleting)
az keyvault secret set-attributes \
--vault-name myapp-vault-prod \
--name old-api-key \
--enabled false
# Delete a secret (soft-delete)
az keyvault secret delete \
--vault-name myapp-vault-prod \
--name old-api-key
# Recover a deleted secret
az keyvault secret recover \
--vault-name myapp-vault-prod \
--name old-api-key
# Purge a deleted secret (permanent, requires purge protection to be off)
az keyvault secret purge \
--vault-name myapp-vault-prod \
--name old-api-key
# Backup and restore
az keyvault secret backup \
--vault-name myapp-vault-prod \
--name db-password \
--file db-password.backup
az keyvault secret restore \
--vault-name myapp-vault-prod \
--file db-password.backupKey Management
# Create an RSA key for encryption
az keyvault key create \
--vault-name myapp-vault-prod \
--name data-encryption-key \
--kty RSA \
--size 4096 \
--ops encrypt decrypt wrapKey unwrapKey
# Create an EC key for signing
az keyvault key create \
--vault-name myapp-vault-prod \
--name signing-key \
--kty EC \
--curve P-256 \
--ops sign verify
# Import an existing key
az keyvault key import \
--vault-name myapp-vault-prod \
--name imported-key \
--pem-file key.pem
# Encrypt data
az keyvault key encrypt \
--vault-name myapp-vault-prod \
--name data-encryption-key \
--algorithm RSA-OAEP-256 \
--value "base64-encoded-plaintext"
# Rotate a key
az keyvault key rotate \
--vault-name myapp-vault-prod \
--name data-encryption-key
# Set key rotation policy
az keyvault key rotation-policy update \
--vault-name myapp-vault-prod \
--name data-encryption-key \
--value '{
"lifetimeActions": [
{
"trigger": {"timeBeforeExpiry": "P30D"},
"action": {"type": "Notify"}
},
{
"trigger": {"timeAfterCreate": "P90D"},
"action": {"type": "Rotate"}
}
],
"attributes": {"expiryTime": "P180D"}
}'Certificate Management
# Create a self-signed certificate
az keyvault certificate create \
--vault-name myapp-vault-prod \
--name app-tls-cert \
--policy '{
"issuerParameters": {"name": "Self"},
"keyProperties": {"exportable": true, "keySize": 4096, "keyType": "RSA"},
"secretProperties": {"contentType": "application/x-pkcs12"},
"x509CertificateProperties": {
"subject": "CN=app.example.com",
"subjectAlternativeNames": {"dnsNames": ["app.example.com", "*.app.example.com"]},
"validityInMonths": 12,
"keyUsage": ["digitalSignature", "keyEncipherment"],
"ekus": ["1.3.6.1.5.5.7.3.1"]
},
"lifetimeActions": [
{"trigger": {"daysBeforeExpiry": 30}, "action": {"actionType": "AutoRenew"}}
]
}'
# Import a certificate
az keyvault certificate import \
--vault-name myapp-vault-prod \
--name imported-cert \
--file certificate.pfx \
--password "pfx-password"
# Download certificate
az keyvault certificate download \
--vault-name myapp-vault-prod \
--name app-tls-cert \
--file cert.pem \
--encoding PEM
# List certificates
az keyvault certificate list --vault-name myapp-vault-prod -o tableAccess Policies and RBAC
RBAC (Recommended)
# Grant secret reader access to a managed identity
az role assignment create \
--role "Key Vault Secrets User" \
--assignee-object-id "$(az identity show -g rg-app -n myapp-identity --query principalId -o tsv)" \
--scope "/subscriptions/{sub}/resourceGroups/rg-secrets/providers/Microsoft.KeyVault/vaults/myapp-vault-prod"
# Grant admin access to security team
az role assignment create \
--role "Key Vault Administrator" \
--assignee "[email protected]" \
--scope "/subscriptions/{sub}/resourceGroups/rg-secrets/providers/Microsoft.KeyVault/vaults/myapp-vault-prod"
# Available Key Vault RBAC roles:
# - Key Vault Administrator (data-plane objects; not control-plane vault management or role assignments)
# - Key Vault Secrets Officer (manage secrets)
# - Key Vault Secrets User (read secrets)
# - Key Vault Certificates Officer (manage certs)
# - Key Vault Crypto Officer (manage keys)
# - Key Vault Crypto User (use keys for encrypt/decrypt)
# - Key Vault Reader (read metadata only)Access Policies (Legacy)
Use set-policy only on the explicitly created legacy-policy dev vault; it does not grant access to RBAC-enabled production vaults. Do not switch a live vault’s access model without a migration plan and verified roles.
# Grant secret access via access policy
az keyvault set-policy \
--name myapp-vault-dev \
--object-id "$(az identity show -g rg-app -n myapp-identity --query principalId -o tsv)" \
--secret-permissions get list
# Grant key access
az keyvault set-policy \
--name myapp-vault-dev \
--object-id "$OBJECT_ID" \
--key-permissions get unwrapKey wrapKey
# Grant certificate access
az keyvault set-policy \
--name myapp-vault-dev \
--object-id "$OBJECT_ID" \
--certificate-permissions get listApplication Integration
Python SDK
from azure.identity import DefaultAzureCredential, ManagedIdentityCredential
from azure.keyvault.secrets import SecretClient
from azure.keyvault.keys import KeyClient
from azure.keyvault.certificates import CertificateClient
# Use DefaultAzureCredential (works locally and in Azure)
credential = DefaultAzureCredential()
vault_url = "https://myapp-vault-prod.v… (nội dung đầy đủ có trong gói tải về)
Skill liên quan
- azure-keyvault-keys-ts – Quản lý khóa mật mã bằng SDK Azure Key Vault Keys cho JavaScript (@azure/keyvault-keys)…
- azure-keyvault-py – SDK Azure Key Vault cho Python. Dùng để quản lý secret, khóa và chứng chỉ với lưu trữ an…
- azure-keyvault-secrets-ts – Quản lý secret bằng Azure Key Vault Secrets SDK cho JavaScript…
- azure-maps-search-dotnet – Azure Maps SDK cho .NET. Dịch vụ định vị bao gồm geocoding, routing, rendering…
- azure-messaging-webpubsubservice-py – Azure Web PubSub Service SDK cho Python. Dùng cho nhắn tin thời gian thực, kết nối…
- azure-mgmt-apicenter-dotnet – Azure API Center SDK cho .NET. Quản lý tập trung kho API với quản trị, phiên bản hóa và…
- azure-mgmt-apicenter-py – Azure API Center Management SDK cho Python. Dùng để quản lý kho API, metadata và quản…
- azure-mgmt-apimanagement-dotnet – Azure Resource Manager SDK cho API Management trong .NET.