Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)48k · #3937

azure-identity-rust

Skill này làm gì

Công cụ này giúp các chương trình viết bằng Rust kết nối an toàn với các dịch vụ Microsoft Azure. Nó quản lý cách chương trình nhận diện chính mình và chứng minh được quyền truy cập tài nguyên.

Khi nào nên dùng

  • ✓Khi bạn phát triển chương trình Rust cần truy cập Azure trên máy tính cục bộ.
  • ✓Khi chương trình đã chạy trên một dịch vụ Azure (như máy ảo hoặc ứng dụng web).
  • ✓Khi bạn cấu hình chương trình dùng “service principal” với secret hoặc chứng chỉ để truy cập Azure.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-identity-rust/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-identity-rust/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm sao để chương trình Rust của tôi kết nối với Azure bằng thông tin đăng nhập dòng lệnh?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ thử nhiều cách để chứng minh danh tính của chương trình, bắt đầu từ các công cụ phát triển đã cài trên máy tính của bạn. Nếu không tìm thấy, nó có thể dùng danh tính được cấu hình trực tiếp trong Azure hoặc các secret bạn cung cấp.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết 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.0

Environment 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.

…

Câu hỏi thường gặp

Cách tốt nhất để dùng khi phát triển trên máy cá nhân là gì?

Dùng `DeveloperToolsCredential`. Nó thử dùng Azure CLI hoặc Azure Developer CLI, những công cụ bạn có thể đã cài sẵn để đăng nhập.

Nếu chương trình của tôi đã chạy trên Azure thì sao?

Dùng `ManagedIdentityCredential`. Azure tự xử lý xác thực mà không cần mật khẩu hay secret.

Tôi có thể dùng lại cùng một cấu hình xác thực cho nhiều client không?

Có. Thông tin đăng nhập có thể được sao chép dễ dàng và dùng cho nhiều client Azure.

Chi tiết

Mô tả gốc của tác giả

Azure Identity SDK for Rust authentication. Use for DeveloperToolsCredential, ManagedIdentityCredential, ClientSecretCredential, and token-based authentication.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#3937
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự