技能 azure-identity-ts
📦

azure-identity-ts

安全

對 Azure 服務���行驗證

此技能提供使用適用於 JavaScript 和 TypeScript 的 Azure Identity SDK 對 Azure 服務進行驗證的文件和範例。它支援多種驗證方法,包括受控識別、服務主體和開發人員認證。

支援: Claude Codex Code(CC)
📊 70 充足
1

下載技能 ZIP

2

在 Claude 中上傳

前往 設定 → 功能 → 技能 → 上傳技能

3

開啟並開始使用

測試它

正在使用「azure-identity-ts」。 如何使用 DefaultAzureCredential 進行驗證?

預期結果:

使用 DefaultAzureCredential 自動選擇驗證方法:

```typescript
import { DefaultAzureCredential } from '@azure/identity';
import { BlobServiceClient } from '@azure/storage-blob';

const credential = new DefaultAzureCredential();
const blobClient = new BlobServiceClient(
'https://<account>.blob.core.windows.net',
credential
);
```

認證鏈依序嘗試:Environment → Workload Identity → Managed Identity → VS Code → Azure CLI → Azure PowerShell → Azure Developer CLI

正在使用「azure-identity-ts」。 為我的 Azure 函數設定受控識別

預期結果:

對具有系統指派識別的 Azure Functions 使用 ManagedIdentityCredential:

```typescript
import { ManagedIdentityCredential } from '@azure/identity';

const credential = new ManagedIdentityCredential();
// 若為使用者指派識別,傳入 clientId:
// const credential = new ManagedIdentityCredential({ clientId: '<user-assigned-client-id>' });
```

安全審計

安全
v1 • 2/24/2026

This is a documentation skill for Azure Identity SDK. Static findings are false positives - the skill documents authentication methods (environment variables, CLI commands, certificate paths) which are standard for authentication library documentation. No executable code, no credential handling, only documentation with placeholder values.

1
已掃描檔案
309
分析行數
5
發現項
1
審計總數

高風險問題 (2)

External Commands Documentation (False Positive)
Lines 67, 197, 200, 202, 259 reference CLI commands (az login, azd auth login, Connect-AzAccount). These are documentation showing what commands Azure SDK invokes, not actual execution. The skill is documentation only.
Environment Variables Documentation (False Positive)
Lines 24-26, 32-33, 41-42 document AZURE_TENANT_ID, AZURE_CLIENT_ID, etc. This is standard documentation for authentication libraries - showing users what environment variables the SDK expects.
中風險問題 (1)
Network URL Documentation (False Positive)
Lines 56 and 234 contain example Azure URLs (blob.core.windows.net, cognitiveservices.azure.com). These are example endpoints for documentation purposes, not actual network calls.
低風險問題 (2)
Certificate Path Documentation (False Positive)
Lines 34, 118, 126 show example certificate paths like /path/to/cert.pem. These are placeholder examples in documentation, not actual sensitive files.
Filesystem Path Documentation (False Positive)
Line 234 shows Kubernetes path /var/run/secrets/tokens/azure-identity. This is documentation about workload identity token locations, not actual file access.
審計者: claude

品質評分

38
架構
100
可維護性
85
內容
50
社群
76
安全
100
規範符合性

你能建構什麼

Azure App Service 驗證

為在 Azure App Service 上執行的 Node.js 應用程式設定受控識別驗證以存取 Azure Storage

CI/CD 管線驗證

設定服務主體驗證以進行自動化部署,無需互動式登入

本機開發設定

使用 Azure CLI 認證進行本機開發,使用與生產環境相同的驗證流程

試試這些提示

基本 Azure 驗證
如���在 TypeScript 專案中使用 DefaultAzureCredential 對 Azure 進行驗證?
受控識別設定
展示如何使用受控識別從 Azure VM 進行驗證
服務主體驗證
如何使用具有用戶端金鑰的服務主體進行驗證?
自訂認證鏈
建立自訂認證鏈,先嘗試受控識別,然後備選至 Azure CLI

最佳實務

  • 在大多數情況下使用 DefaultAzureCredential - 它會自動選擇最佳的驗證方法
  • 在生產環境中偏好使用受控識別以避免儲存機密
  • 使用 ChainedTokenCredential 建立具有可靠性的自訂備選鏈

避免

  • 在原始碼中硬式編碼用戶端金鑰 - 請改用環境變數
  • 在生產環境中使用互動式認證 - 請使用受控識別或服務主體
  • 忽略認證鏈失敗 - 始终設定適當的備選選項

常見問題

什麼是 DefaultAzureCredential?
DefaultAzureCredential 是一個依序嘗試多種驗證方法的鏈:EnvironmentCredential、WorkloadIdentityCredential、ManagedIdentityCredential、VisualStudioCodeCredential、AzureCliCredential、AzurePowerShellCredential 和 AzureDeveloperCliCredential。它可在開發和生產環境中自動運作。
何時應使用受控識別?
當您的應用程式在支援受控識別的 Azure 服務(App Service、VM、AKS、Functions)上執行時,請使用受控識別。它消除了管理機密的需求,是生產環境 Azure 工作負載的建議驗證方法。
如何在開發期間進行本機驗證?
在本機開發期間使用 AzureCliCredential、AzurePowerShellCredential 或 AzureDeveloperCliCredential。執行一次 'az login'、'Connect-AzAccount' 或 'azd auth login' 進行驗證,SDK 將使用這些認證。
服務主體和受控識別有什麼差別?
服務主體是您在 Azure AD 中手動建立和管理的應用程式註冊。受控識別是 Azure 為 VM 或 App Service 等資源自動建立的識別。受控識別不需要機密管理。
我可以使用憑證進行驗證嗎?
可以,搭配憑證路徑和選用密碼使用 ClientCertificateCredential,或設定 AZURE_CLIENT_CERTIFICATE_PATH 環境變數。這對於服務主體驗證而言,比用戶端金鑰更安全。
如何處理主權雲端?
建立認證時,搭配 AzureAuthorityHosts(AzureGovernment、AzureChina)使用 authorityHost 選項。在認證建構函式選項中傳入它。

開發者詳情

檔案結構

📄 SKILL.md