Skip to main content
skill

azure-keyvault-secrets-ts — Claude Code skill: how to install

Teaches coding agents to manage secrets, encryption keys, and cryptographic operations in Azure Key Vault via official TypeScript SDKs.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add microsoft/skills --skill azure-keyvault-secrets-ts -a claude-code
Open on GitHub

What azure-keyvault-secrets-ts does

This skill injects ready-made patterns for @azure/keyvault-secrets, @azure/identity, and @azure/keyvault-keys into your agent. It guides the model through proper authentication, favoring DefaultAzureCredential during local development and ManagedIdentityCredential in production environments.

Code patterns cover setting tagged secrets, listing secret versions, handling soft-deletes, and managing Key Vault backups. It also includes steps for RSA key rotation policies and payload encryption using CryptographyClient.

The underlying Azure SDKs target Node.js runtimes. Browser environments will fail immediately.

What it helps with

  • store application secrets with tags and expiration dates in Azure Key Vault
  • authenticate securely using DefaultAzureCredential or managed identities
  • manage soft-delete, purge, and secret recovery workflows
  • configure automated key rotation policies for RSA or EC keys
  • encrypt and decrypt payloads using CryptographyClient

Example prompts for the agent

  • Write a TypeScript snippet to set an expiring secret in Azure Key Vault using @azure/keyvault-secrets.
  • Show how to rotate an RSA key and attach an automated rotation policy in Node.js.
  • Implement payload signing and verification with CryptographyClient.

How to install azure-keyvault-secrets-ts

1Skills CLI (Vercel)

npx skills add microsoft/skills --skill azure-keyvault-secrets-ts -a claude-code

2Manually: put the files in place

~/.claude/skills/azure-keyvault-secrets-ts/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/azure-keyvault-secrets-ts/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about azure-keyvault-secrets-ts

How to install azure-keyvault-secrets-ts in Claude Code?

Run npx skills add microsoft/skills --skill azure-keyvault-secrets-ts -a claude-code in your terminal. Alternatively, add the configuration file directly at ~/.claude/skills/azure-keyvault-secrets-ts/SKILL.md.

What does azure-keyvault-secrets-ts do?

It instructs your AI assistant on interacting with Azure Key Vault secrets and keys using TypeScript SDKs in Node.js.

Does this skill support client-side browser code?

No. The Azure Key Vault SDKs referenced here are strictly designed for Node.js environments and do not function in browsers.

Source text

SKILL.md · MIT
---
name: azure-keyvault-secrets-ts
description: Manage secrets using Azure Key Vault Secrets SDK for JavaScript (@azure/keyvault-secrets). Use when storing and retrieving application secrets or configuration values.
license: MIT
metadata:
  author: Microsoft
  version: "1.0.0"
  package: '@azure/keyvault-secrets'
---

# Azure Key Vault Secrets SDK for TypeScript

Manage secrets with Azure Key Vault.

## Installation

```bash
# Secrets SDK
npm install @azure/keyvault-secrets @azure/identity
```

## Environment Variables

```bash
KEY_VAULT_URL=https://<vault-name>.vault.azure.net
# Or
AZURE_KEYVAULT_NAME=<vault-name>
AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production
```

## Authentication

```typescript
import { DefaultAzureCredential, ManagedIdentityCredential } from "@azure/identity";
import { SecretClient } from "@azure/keyvault-secrets";

// Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential>
const credential = new DefaultAzureCredential({requiredEnvVars: ["AZURE_TOKEN_CREDENTIALS"]});
// Or use a specific credential directly in production:
// See https://learn.microsoft.com/javascript/api/overview/azure/identity-readme?view=azure-node-latest#credential-classes
// const credential = new ManagedIdentityCredential();
const vaultUrl = `https://${process.env.AZURE_KEYVAULT_NAME}.vault.azure.net`;

const keyClient = new KeyClient(vaultUrl, credential);
const secretClient = new SecretClient(vaultUrl, credential);
```

## Secrets Operations

### Create/Set Secret

```typescript
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

```typescript
// Get latest version
const secret = await secretClient.getSecret("MySecret");
console.log(secret.value);

// Get specific version
const specificSecret = await secretClient.getSecret("MySecret", {
  version: secret.properties.version
});
```

### List Secrets

```typescript
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

```typescript
// 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

```typescript
// 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

```typescript
const key = await keyClient.getKey("MyKey");
console.log(key.name, key.keyType);
```

### List Keys

```typescript
for await (const keyProperties of keyClient.listPropertiesOfKeys()) {
  console.log(keyProperties.name);
}
```

### Rotate Key

```typescript
// Manual rotation
const rotatedKey = await keyClient.rotateKey("MyKey");

// Set rotation policy
await keyClient.updateKeyRotationPolicy("MyKey", {
  lifetimeActions: [{ action: "Rotate", timeBeforeExpiry: "P30D" }],
  expiresIn: "P90D"
});
```

### Delete Key

```typescript
const deletePoller = await keyClient.beginDeleteKey("MyKey");
await deletePoller.pollUntilDone();

// Purge
await keyClient.purgeDeletedKey("MyKey");
```

## Cryptographic Operations

### Create CryptographyClient

```typescript
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

```typescript
// 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
});

console.log(decryptResult.result.toString());
```

### Sign/Verify

```typescript
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

```typescript
// 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

```typescript
// Backup
const keyBackup = await keyClient.backupKey("MyKey");
const secretBackup = await secretClient.backupSecret("MySecret");

// Restore (can restore to different vault)
const restoredKey = await keyClient.restoreKeyBackup(keyBackup!);
const restoredSecret = await secretClient.restoreSecretBackup(secretBackup!);
```

## Key Types

```typescript
import {
  KeyClient,
  KeyVaultKey,
  KeyProperties,
  DeletedKey,
  CryptographyClient,
  KnownEncryptionAlgorithms,
  KnownSignatureAlgorithms
} from "@azure/keyvault-keys";

import {
  SecretClient,
  KeyVaultSecret,
  SecretProperties,
  DeletedSecret
} from "@azure/keyvault-secrets";
```

## Error Handling

```typescript
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` for local development; use `ManagedIdentityCredential` or `WorkloadIdentityCredential` for 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

© Microsoft · MIT · microsoft/skills

Similar skills

All skills for Cloud: AWS, Azure, GCP →

From the same set242

The whole set →
azure-storage-blob-ts Teaches the agent to manage Azure Blob Storage via @azure/storage-blob in Node.js and TypeScript. Helpful for uploading files, streams, and configuring SAS tokens. 1installs azure-search-documents-ts A skill that gives your agent working TypeScript patterns for the Azure AI Search SDK: indexes, vector and hybrid search, semantic ranking. 1installs azure-postgres-ts Guides TypeScript and Node.js setup for Azure Database for PostgreSQL Flexible Server using node-postgres with password or Entra ID auth. 1installs azure-monitor-opentelemetry-ts This skill guides you through adding Azure Monitor and OpenTelemetry to Node.js apps for Application Insights traces, metrics, and logs. 1installs azure-keyvault-keys-ts This skill guides TypeScript work with Azure Key Vault keys, from creation and rotation to encryption and signing. Use it when building with the @azure/keyvault-keys SDK. 1installs azure-identity-ts A skill that walks the agent through Azure authentication with the @azure/identity library in TypeScript. Useful once DefaultAzureCredential or managed identity shows up in your code. 1installs azure-eventhub-ts Guides AI coding assistants on streaming events with Azure Event Hubs and TypeScript. Handy for ingesting IoT telemetry and processing partitioned real-time streams. 1installs azure-cosmos-ts A skill covering the Azure Cosmos DB JavaScript/TypeScript SDK: document CRUD, queries, bulk operations. Useful when the agent writes data-access code. 1installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor