Azure Key Vault 机密管理
azure-keyvault-secrets-ts
使用适用于 JavaScript 的 Azure Key Vault Secrets SDK(@azure/keyvault-secrets)管理机密。在存储和检索应用程序机密或配置值时使用。
- License 许可
- MIT
- 所属仓库
- microsoft/skills
- 最近更新
- 2026-11-14
- Stars
- ★ 3.2k
- Forks
- 368
01 前言 Front Matter
- name
- azure-keyvault-secrets-ts
- license
- MIT
- metadata
- { "author": "Microsoft", "package": "@azure/keyvault-secrets", "version": "1.0.0" }
- description
- Manage secrets using Azure Key Vault Secrets SDK for JavaScript (@azure/keyvault-secrets). Use when storing and retrieving application secrets or configuration values.
02 资源文件 112
- 参考文档copilot-studio/agent.sync.yaml174 B
- 参考文档copilot-studio/behaviors/aibast_flag-for-review.mcs.yml1.0 KB
- 参考文档copilot-studio/behaviors/aibast_interpretation.mcs.yml1.0 KB
- 参考文档copilot-studio/behaviors/aibast_quick-reference.mcs.yml1.0 KB
- 参考文档copilot-studio/behaviors/aibast_review-queue.mcs.yml995 B
- 参考文档copilot-studio/behaviors/aibast_scope-job.mcs.yml1002 B
- 参考文档copilot-studio/behaviors/aibast_vetted-lookup.mcs.yml1.0 KB
- 参考文档copilot-studio/capabilities/knowledge/files/aibast_engineering-standards-advisor-rules-and-guardrails.md3.1 KB
- 参考文档copilot-studio/capabilities/knowledge/files/aibast_engineering-standards-advisor-rules-and-guardrails.md.mcs.yml224 B
- 参考文档copilot-studio/capabilities/knowledge/files/aibast_engineering-standards-advisor-synthetic-records.md15.9 KB
- 参考文档copilot-studio/capabilities/knowledge/files/aibast_engineering-standards-advisor-synthetic-records.md.mcs.yml218 B
- 参考文档copilot-studio/settings.mcs.yml4.4 KB
- 参考文档deployment.json5.3 KB
- 参考文档EASY-MODE-COPILOT-CHAT.md233 B
- 参考文档EASY-MODE-PERSONLESS.md233 B
- 参考文档EASY-MODE.md2.7 KB
- 参考文档evals/copilot-studio-preview-evidence.json2.1 KB
- 参考文档evals/dataverse-draft-evidence.json1.6 KB
- 参考文档evals/manual-build-evidence.json3.7 KB
- 参考文档evals/onepager-map.json2.8 KB
- 参考文档evals/source-audit.json1.6 KB
- 参考文档evals/transcripts.json14.1 KB
- 参考文档evals/visual-checkpoints.json30.2 KB
- 参考文档evidence-report.html31.1 KB
- 参考文档export-manifest.json57.7 KB
- 资产文件exports/engineering-standards-advisor-copilot-studio-solution.zip43.9 KB
- 参考文档exports/engineering-standards-advisor-deployment-settings.json216 B
- 参考文档exports/engineering-standards-advisor-solution-export.json1.2 KB
- 参考文档exports/README.md1.6 KB
- 参考文档field-guide.html38.0 KB
- 参考文档FIELD-GUIDE.md13.8 KB
- 参考文档manual-tutorial.html93.0 KB
- 参考文档manual/GLOBAL-INSTRUCTIONS.md3.6 KB
- 参考文档manual/knowledge/aibast_engineering-standards-advisor-rules-and-guardrails.md3.1 KB
- 参考文档manual/knowledge/aibast_engineering-standards-advisor-synthetic-records.md15.9 KB
- 参考文档quest.html146.4 KB
- 参考文档README.md3.8 KB
- 参考文档references/keys.md11.8 KB
- 参考文档references/secrets.md13.3 KB
- 资产文件screenshots/assisted/01-review-build.jpg127.9 KB
- 资产文件screenshots/assisted/02-esa-01.jpg82.1 KB
- 资产文件screenshots/assisted/03-esa-02.jpg132.5 KB
- 资产文件screenshots/assisted/04-esa-03.jpg127.1 KB
- 资产文件screenshots/assisted/05-esa-04.jpg134.1 KB
- 资产文件screenshots/assisted/06-esa-05.jpg119.9 KB
- 资产文件screenshots/assisted/07-esa-06.jpg125.3 KB
- 资产文件screenshots/assisted/08-confirm-draft.jpg28.7 KB
- 资产文件screenshots/assisted/annotated/01-review-build.png140.0 KB
- 资产文件screenshots/assisted/annotated/02-esa-01.png82.1 KB
- 资产文件screenshots/assisted/annotated/03-esa-02.png133.3 KB
- 资产文件screenshots/assisted/annotated/04-esa-03.png126.0 KB
- 资产文件screenshots/assisted/annotated/05-esa-04.png132.1 KB
- 资产文件screenshots/assisted/annotated/06-esa-05.png120.8 KB
- 资产文件screenshots/assisted/annotated/07-esa-06.png122.2 KB
- 资产文件screenshots/assisted/annotated/08-confirm-draft.png29.5 KB
- 参考文档screenshots/assisted/browserfilm.json1.6 KB
- 资产文件screenshots/assisted/copilot-assisted-contact-sheet.jpg210.5 KB
- 资产文件screenshots/assisted/copilot-assisted-walkthrough.gif1.2 MB
- 参考文档screenshots/assisted/README.md467 B
- 资产文件screenshots/manual/01-create-blank-agent.jpg57.7 KB
- 资产文件screenshots/manual/02-name-agent.jpg58.2 KB
- 资产文件screenshots/manual/03-enter-instructions.jpg136.6 KB
- 资产文件screenshots/manual/04-save-instructions.jpg139.4 KB
- 资产文件screenshots/manual/05-remove-web-search.jpg136.3 KB
- 资产文件screenshots/manual/06-add-aibast-engineering-standards-advisor-rules-and-guardrails.jpg138.6 KB
- 资产文件screenshots/manual/07-add-aibast-engineering-standards-advisor-synthetic-records.jpg141.5 KB
- 资产文件screenshots/manual/08-add-aibast-flag-for-review-03.jpg144.1 KB
- 资产文件screenshots/manual/09-add-aibast-interpretation-02.jpg145.3 KB
- 资产文件screenshots/manual/10-add-aibast-quick-reference-05.jpg146.7 KB
- 资产文件screenshots/manual/11-add-aibast-review-queue-04.jpg147.9 KB
- 资产文件screenshots/manual/12-add-aibast-scope-job-06.jpg149.0 KB
- 资产文件screenshots/manual/13-add-aibast-vetted-lookup-01.jpg149.2 KB
- 资产文件screenshots/manual/14-review-inventory.jpg149.2 KB
- 资产文件screenshots/manual/15-review-skills.jpg140.5 KB
- 资产文件screenshots/manual/16-review-skills-more.jpg143.1 KB
- 资产文件screenshots/manual/17-open-preview.jpg32.9 KB
- 资产文件screenshots/manual/18-esa-01.jpg87.2 KB
- 资产文件screenshots/manual/19-esa-02.jpg106.5 KB
- 资产文件screenshots/manual/20-esa-03.jpg153.1 KB
- 资产文件screenshots/manual/21-esa-04.jpg132.3 KB
- 资产文件screenshots/manual/22-esa-05.jpg112.4 KB
- 资产文件screenshots/manual/23-esa-06.jpg121.0 KB
- 资产文件screenshots/manual/24-confirm-draft.jpg29.0 KB
- 资产文件screenshots/manual/annotated/01-create-blank-agent.png62.7 KB
- 资产文件screenshots/manual/annotated/02-name-agent.png64.4 KB
- 资产文件screenshots/manual/annotated/03-enter-instructions.png139.4 KB
- 资产文件screenshots/manual/annotated/04-save-instructions.png135.5 KB
- 资产文件screenshots/manual/annotated/05-remove-web-search.png138.8 KB
- 资产文件screenshots/manual/annotated/06-add-aibast-engineering-standards-advisor-rules-and-guardrails.png142.7 KB
- 资产文件screenshots/manual/annotated/07-add-aibast-engineering-standards-advisor-synthetic-records.png145.0 KB
- 资产文件screenshots/manual/annotated/08-add-aibast-flag-for-review-03.png144.9 KB
- 资产文件screenshots/manual/annotated/09-add-aibast-interpretation-02.png145.8 KB
- 资产文件screenshots/manual/annotated/10-add-aibast-quick-reference-05.png147.1 KB
- 资产文件screenshots/manual/annotated/11-add-aibast-review-queue-04.png147.9 KB
- 资产文件screenshots/manual/annotated/12-add-aibast-scope-job-06.png148.7 KB
- 资产文件screenshots/manual/annotated/13-add-aibast-vetted-lookup-01.png149.4 KB
- 资产文件screenshots/manual/annotated/14-review-inventory.png157.5 KB
- 资产文件screenshots/manual/annotated/15-review-skills.png155.4 KB
- 资产文件screenshots/manual/annotated/16-review-skills-more.png161.3 KB
- 资产文件screenshots/manual/annotated/17-open-preview.png32.4 KB
- 资产文件screenshots/manual/annotated/18-esa-01.png88.6 KB
- 资产文件screenshots/manual/annotated/19-esa-02.png110.6 KB
- 资产文件screenshots/manual/annotated/20-esa-03.png148.4 KB
- 资产文件screenshots/manual/annotated/21-esa-04.png134.9 KB
- 资产文件screenshots/manual/annotated/22-esa-05.png116.0 KB
- 资产文件screenshots/manual/annotated/23-esa-06.png123.2 KB
- 资产文件screenshots/manual/annotated/24-confirm-draft.png29.9 KB
- 参考文档screenshots/manual/browserfilm.json4.2 KB
- 资产文件screenshots/manual/manual-build-contact-sheet.jpg869.5 KB
- 资产文件screenshots/manual/manual-build-walkthrough.gif5.6 MB
- 参考文档screenshots/manual/README.md461 B
- 参考文档screenshots/README.md521 B
03 SKILL.md 正文
Azure Key Vault Secrets SDK for TypeScript
Manage secrets with Azure Key Vault.
Installation
# Secrets SDK
npm install @azure/keyvault-secrets @azure/identity
Environment Variables
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
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
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.value);
// 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
});
console.log(decryptResult.result.toString());
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 (can restore to different vault)
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
- Use
DefaultAzureCredentialfor local development; useManagedIdentityCredentialorWorkloadIdentityCredentialfor production - Enable soft-delete - Required for production vaults
- Set expiration dates - On both keys and secrets
- Use key rotation policies - Automate key rotation
- Limit key operations - Only grant needed operations (encrypt, sign, etc.)
- Browser not supported - These SDKs are Node.js only
04 同仓库更多 Skills
azure-advisor-cost-optimization
Analyze Azure Advisor Cost/IdleResources findings and prevalidate deletion safety, including Service Groups. WHEN: "find unused Azure resources", "what resources am I paying for but no longer using", "idle-resource savings", "historical idle-resource savings", "are these idle resources safe to delete". Generic Cost, other subcategories, and cross-category requests use azure-advisor.
Azure 技能创建与更新指南
skill-creator
面向使用 Azure SDK 和 Microsoft Foundry 服务的 AI 编码智能体,指导其创建高效技能的指南。在创建新技能或更新现有技能时使用。
AI 播客音频生成
podcast-generation
通过 WebSocket 使用 Azure OpenAI 的 GPT Realtime Mini 模型生成 AI 驱动的播客式音频叙述。当构建文本转语音功能、音频叙述生成、根据内容制作播客,或集成 Azure OpenAI Realtime API 以获得真实音频输出时使用。涵盖从 React 前端到 Python FastAPI 后端及 WebSocket 流式传输的全栈实现。
Microsoft 技术文档查询
microsoft-docs
通过查询官方文档来理解 Microsoft 技术。当用户询问某项技术的工作原理、想要教程、需要任何 Microsoft 技术(Azure、.NET、M365、Windows、Power Platform 等)的配置选项、限制、配额或最佳实践时使用——即使他们没有提到"文档"。如果问题是为了理解概念而非编写代码,那么这就是合适的技能。
MCP 服务器构建
mcp-builder
用于创建高质量 MCP(Model Context Protocol)服务器的指南,使大语言模型能够通过设计完善的工具与外部服务交互。当构建用于集成外部 API 或服务的 MCP 服务器时使用,无论采用 Python(FastMCP)、Node/TypeScript(MCP SDK),还是 C#/.NET(Microsoft MCP SDK)。
KQL 查询编写与调试
kql
KQL 语言专业能力,用于编写正确且高效的 Kusto Query Language 查询。涵盖语法陷阱、join 模式、dynamic 类型、datetime 陷阱、regex 模式、序列化、内存管理、结果集规模控制,以及高级函数(geo、vector、graph)。在编写、调试或审查 KQL 查询时均使用本技能——即使是简单查询——因为陷阱章节可防止最常见的错误,避免浪费工具调用并引发代价高昂的连锁重试。触发条件:KQL、Kusto、ADX、Azure Data Explorer、Fabric Real-Time Intelligence、EventHouse、Log Analytics、日志分析、数据探索、时间序列、异常检测、summarize、where 子句、join、extend、project、let 语句、parse 运算符、extract 函数,以及任何提及管道式查询语法的情形。