azure-keyvault-keys-ts – DevOps & Infrastructure skill for AI agents
Manage cryptographic keys using Azure Key Vault Keys SDK for JavaScript (@azure/keyvault-keys). Use when creating, encrypting/decrypting, signing, or rotating keys.
Install the azure-keyvault-keys-ts skill with one command
Pick the tool you use, copy the command and paste it in your terminal. The skill lands in that tool's skills folder and is ready in your next session.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-keyvault-keys-ts-b38a7.tgz | tar xz -C ~/.claude/skills
Call it in Claude Code: /azure-keyvault-keys-ts – then describe the task you want done.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-keyvault-keys-ts-b38a7.tgz | tar xz -C ~/.codex/skills
Call it in Codex: $azure-keyvault-keys-ts – then describe the task you want done.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-keyvault-keys-ts-b38a7.tgz | tar xz -C ~/.hermes/skills
Call it in Hermes Agent: /azure-keyvault-keys-ts – then describe the task you want done.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-keyvault-keys-ts-b38a7.tgz | tar xz -C ~/.deepcode/skills
Call it in DeepSeek: /azure-keyvault-keys-ts – then describe the task you want done.
SKILL.md content
Azure Key Vault Keys SDK for TypeScript
Manage cryptographic keys with Azure Key Vault.
Installation
# Keys SDK
npm install @azure/keyvault-keys @azure/keyvault-secrets @azure/identityEnvironment Variables
KEY_VAULT_URL=https://<vault-name>.vault.azure.net
# Or
AZURE_KEYVAULT_NAME=<vault-name>Authentication
import { DefaultAzureCredential } from "@azure/identity";
import { KeyClient, CryptographyClient } from "@azure/keyvault-keys";
import { SecretClient } from "@azure/keyvault-secrets";
const credential = new DefaultAzureCredential();
const vaultUrl = `https://${process.env.AZURE_KEYVAULT_NAME}.vault.azure.net`;
const keyClient = new KeyClient(vaultUrl, credential);
const secretClient = new SecretClient(vaultUrl, credential);Execution boundaries
Examples are independent fragments and reuse names; do not concatenate them into one script. Use approved test vaults and least-privilege identity. Purge is irreversible and can be blocked by purge protection; key deletion/rotation can break dependent workloads. Confirm exact vault/object/version and recovery plan before mutation. Example expiration dates are historical, not recommended live values.
Secrets Operations
Create/Set Secret
const secret = await secretClient.setSecret("MySecret", "secret-value");
// With attributes
const secretWithAttrs = await secretClient.setSecret("MySecret", "value", {
enabled: true,
expiresOn: new Date("2025-12-31"),
contentType: "application/json",
tags: { environment: "production" }
});Get Secret
// Get latest version
const secret = await secretClient.getSecret("MySecret");
console.log(secret.name); // Never log secret values.
// Get specific version
const specificSecret = await secretClient.getSecret("MySecret", {
version: secret.properties.version
});List Secrets
for await (const secretProperties of secretClient.listPropertiesOfSecrets()) {
console.log(secretProperties.name);
}
// List versions
for await (const version of secretClient.listPropertiesOfSecretVersions("MySecret")) {
console.log(version.version);
}Delete Secret
// Soft delete
const deletePoller = await secretClient.beginDeleteSecret("MySecret");
await deletePoller.pollUntilDone();
// Purge (permanent)
await secretClient.purgeDeletedSecret("MySecret");
// Recover
const recoverPoller = await secretClient.beginRecoverDeletedSecret("MySecret");
await recoverPoller.pollUntilDone();Keys Operations
Create Keys
// Generic key
const key = await keyClient.createKey("MyKey", "RSA");
// RSA key with size
const rsaKey = await keyClient.createRsaKey("MyRsaKey", { keySize: 2048 });
// Elliptic Curve key
const ecKey = await keyClient.createEcKey("MyEcKey", { curve: "P-256" });
// With attributes
const keyWithAttrs = await keyClient.createKey("MyKey", "RSA", {
enabled: true,
expiresOn: new Date("2025-12-31"),
tags: { purpose: "encryption" },
keyOps: ["encrypt", "decrypt", "sign", "verify"]
});Get Key
const key = await keyClient.getKey("MyKey");
console.log(key.name, key.keyType);List Keys
for await (const keyProperties of keyClient.listPropertiesOfKeys()) {
console.log(keyProperties.name);
}Rotate Key
// Manual rotation
const rotatedKey = await keyClient.rotateKey("MyKey");
// Set rotation policy
await keyClient.updateKeyRotationPolicy("MyKey", {
lifetimeActions: [{ action: "Rotate", timeBeforeExpiry: "P30D" }],
expiresIn: "P90D"
});Delete Key
const deletePoller = await keyClient.beginDeleteKey("MyKey");
await deletePoller.pollUntilDone();
// Purge
await keyClient.purgeDeletedKey("MyKey");Cryptographic Operations
Create CryptographyClient
import { CryptographyClient } from "@azure/keyvault-keys";
// From key object
const cryptoClient = new CryptographyClient(key, credential);
// From key ID
const cryptoClient = new CryptographyClient(key.id!, credential);Encrypt/Decrypt
// Encrypt
const encryptResult = await cryptoClient.encrypt({
algorithm: "RSA-OAEP",
plaintext: Buffer.from("My secret message")
});
// Decrypt
const decryptResult = await cryptoClient.decrypt({
algorithm: "RSA-OAEP",
ciphertext: encryptResult.result
});
// Use decrypted bytes only in the authorized application; do not log them.Sign/Verify
import { createHash } from "node:crypto";
// Create digest
const hash = createHash("sha256").update("My message").digest();
// Sign
const signResult = await cryptoClient.sign("RS256", hash);
// Verify
const verifyResult = await cryptoClient.verify("RS256", hash, signResult.result);
console.log("Valid:", verifyResult.result);Wrap/Unwrap Keys
// Wrap a key (encrypt it for storage)
const wrapResult = await cryptoClient.wrapKey("RSA-OAEP", Buffer.from("key-material"));
// Unwrap
const unwrapResult = await cryptoClient.unwrapKey("RSA-OAEP", wrapResult.result);Backup and Restore
// Backup
const keyBackup = await keyClient.backupKey("MyKey");
const secretBackup = await secretClient.backupSecret("MySecret");
// Restore only within the same subscription and Azure geography.
const restoredKey = await keyClient.restoreKeyBackup(keyBackup!);
const restoredSecret = await secretClient.restoreSecretBackup(secretBackup!);Key Types
import {
KeyClient,
KeyVaultKey,
KeyProperties,
DeletedKey,
CryptographyClient,
KnownEncryptionAlgorithms,
KnownSignatureAlgorithms
} from "@azure/keyvault-keys";
import {
SecretClient,
KeyVaultSecret,
SecretProperties,
DeletedSecret
} from "@azure/keyvault-secrets";Error Handling
try {
const secret = await secretClient.getSecret("NonExistent");
} catch (error: any) {
if (error.code === "SecretNotFound") {
console.log("Secret does not exist");
} else {
throw error;
}
}Best Practices
1. Use DefaultAzureCredential - Works across dev and production
2. Enable soft-delete - Required for production vaults
3. Set expiration dates - On both keys and secrets
4. Use key rotation policies - Automate key rotation
5. Limit key operations - Only grant needed operations (encrypt, sign, etc.)
6. Browser not supported - These SDKs are Node.js only
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Related skills
- azure-keyvault-py – Azure Key Vault SDK for Python. Use for secrets, keys, and certificates management with…
- azure-keyvault-secrets-ts – Manage secrets using Azure Key Vault Secrets SDK for JavaScript…
- azure-maps-search-dotnet – Azure Maps SDK for .NET. Location-based services including geocoding, routing…
- azure-messaging-webpubsubservice-py – Azure Web PubSub Service SDK for Python. Use for real-time messaging, WebSocket…
- azure-mgmt-apicenter-dotnet – Azure API Center SDK for .NET. Centralized API inventory management with governance…
- azure-mgmt-apicenter-py – Azure API Center Management SDK for Python. Use for managing API inventory, metadata…
- azure-mgmt-apimanagement-dotnet – Azure Resource Manager SDK for API Management in .NET.
- azure-mgmt-apimanagement-py – Azure API Management SDK for Python. Use for managing APIM services, APIs, products…