azure-identity-rust – skill Lập trình cho agent AI
SDK Azure Identity cho xác thực Rust. Dùng cho DeveloperToolsCredential, ManagedIdentityCredential, ClientSecretCredential và xác thực dựa trên token.
Cài skill azure-identity-rust 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-identity-rust-8fe33.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /azure-identity-rust – 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-identity-rust-8fe33.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $azure-identity-rust – 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-identity-rust-8fe33.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /azure-identity-rust – 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-identity-rust-8fe33.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /azure-identity-rust – 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 Identity SDK for Rust
Authentication library for Azure SDK clients using Microsoft Entra ID (formerly Azure AD).
The examples below require a reviewed compatible crate set and replacement of every resource placeholder. Do not use production data for demonstration writes.
Installation
cargo add azure_identity@=1.0.0 azure_core@=1.1.0Environment Variables
# Service Principal (for production/CI)
export AZURE_TENANT_ID="<your-tenant-id>"
export AZURE_CLIENT_ID="<your-client-id>"
: "${AZURE_CLIENT_SECRET:?Inject through the approved host or CI secret manager}"
export AZURE_CLIENT_SECRET
# User-assigned Managed Identity (optional)
export AZURE_CLIENT_ID="<managed-identity-client-id>"DeveloperToolsCredential
The recommended credential for local development. Tries developer tools in order (Azure CLI, Azure Developer CLI):
use azure_identity::DeveloperToolsCredential;
use azure_security_keyvault_secrets::SecretClient;
let credential = DeveloperToolsCredential::new(None)?;
let client = SecretClient::new(
"https://my-vault.vault.azure.net/",
credential.clone(),
None,
)?;Credential Chain Order
| Order | Credential | Environment |
|-------|-----------|-------------|
| 1 | AzureCliCredential | az login |
| 2 | AzureDeveloperCliCredential | azd auth login |
Credential Types
| Credential | Usage |
|------------|-------|
| DeveloperToolsCredential | Local development - tries CLI tools |
| ManagedIdentityCredential | Azure VMs, App Service, Functions, AKS |
| WorkloadIdentityCredential | Kubernetes workload identity |
| ClientSecretCredential | Service principal with secret |
| ClientCertificateCredential | Service principal with certificate |
| AzureCliCredential | Direct Azure CLI auth |
| AzureDeveloperCliCredential | Direct azd CLI auth |
| AzurePipelinesCredential | Azure Pipelines service connection |
| ClientAssertionCredential | Custom assertions (federated identity) |
ManagedIdentityCredential
For Azure-hosted resources:
use azure_identity::{ManagedIdentityCredential, ManagedIdentityCredentialOptions, UserAssignedId};
// System-assigned managed identity
let credential = ManagedIdentityCredential::new(None)?;
// User-assigned managed identity
let options = ManagedIdentityCredentialOptions {
user_assigned_id: Some(UserAssignedId::ClientId("<user-assigned-mi-client-id>".into())),
..Default::default()
};
let credential = ManagedIdentityCredential::new(Some(options))?;ClientSecretCredential
For service principal with secret:
use azure_identity::ClientSecretCredential;
let credential = ClientSecretCredential::new(
"<tenant-id>".into(),
"<client-id>".into(),
"<client-secret>".into(),
None,
)?;Best Practices
1. Use DeveloperToolsCredential for local dev — automatically picks up Azure CLI
2. Use ManagedIdentityCredential in production — no secrets to manage
3. Clone credentials — credentials are Arc-wrapped and cheap to clone
4. Reuse credential instances — same credential can be used with multiple clients
5. Provide the async runtime — add Tokio with the features required by your application; do not assume a crate-specific tokio feature exists
The reviewed example set uses azure_identity 1.0.0 and compatible Azure core/credential crates. Record and commit Cargo.lock; source/API review is not a compiler or live-service test.
Reference Links
| Resource | Link |
|----------|------|
| API Reference | https://docs.rs/azure_identity |
| Source Code | https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/identity/azure_identity |
| crates.io | https://crates.io/crates/azure_identity |
When to Use
Use when choosing or configuring Entra ID credentials for Rust Azure SDK clients: local developer tools, managed/workload identity or a reviewed service principal.
Limitations
- Examples are fragments inside async application code, with compatible pinned Azure crates and the required Tokio/Serde/Futures dependencies; verify the selected version’s API before use. They were reviewed against official source/reference, not compiled or run against a cloud account here.
- Use an authorized tenant, resource and identity with least privilege. Writes, overwrites, deletes, backup retrieval and account changes require the corresponding scope; cleanup may remove only explicitly identified disposable resources. Bound requests, retries and downloaded bytes, and do not log payloads, credentials or secret values.
- 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.
Skill liên quan
- azure-keyvault-certificates-rust – SDK Azure Key Vault Certificates cho Rust. Dùng để tạo, nhập và quản lý chứng chỉ.
- azure-keyvault-keys-rust – SDK Azure Key Vault Keys cho Rust. Dùng để tạo, quản lý và sử dụng khóa mật mã. Từ khóa…
- azure-keyvault-secrets-rust – SDK Azure Key Vault Secrets cho Rust. Dùng để lưu và lấy secret, mật khẩu và API key. Từ…
- azure-messaging-webpubsub-java – Xây dựng ứng dụng web thời gian thực với Azure Web PubSub SDK cho Java. Dùng khi triển…
- modern-javascript-patterns – Thành thạo các tính năng ES6+ như async/await, destructuring, spread operator, arrow…
- monorepo-management – Thành thạo quản lý monorepo với Turborepo, Nx và pnpm workspaces để xây dựng kho nhiều…
- cto-advisor – Hướng dẫn lãnh đạo kỹ thuật cho đội ngũ kỹ sư, quyết định kiến trúc và chiến lược công…
- cto-review – /c-level-agents:cto-review [plan] — Rà soát kiến trúc và khả năng mở rộng. Nợ kỹ thuật…