azure-identity-rust

tarafından microsoft

Azure Identity library for Rust. Microsoft Entra ID authentication for all Azure SDK clients. Triggers: "azure identity rust", "DeveloperToolsCredential", "authentication rust", "managed identity rust", "credential rust", "Entra ID rust".

npx skills add https://github.com/microsoft/skills --skill azure-identity-rust

Azure Identity library for Rust

Microsoft Entra ID authentication for Azure SDK clients.

Use this skill when:

  • An app needs to authenticate to Azure services from Rust
  • You need DeveloperToolsCredential for local development
  • You need ManagedIdentityCredential for Azure-hosted workloads
  • You need service principal auth with secret or certificate

IMPORTANT: Only use official azure_* crates published by the azure-sdk crates.io user. Do NOT use the deprecated azure_sdk_* crates (MindFlavor/AzureSDKForRust) or community crates. Official crates use underscores in names and none have version 0.21.0.

Note: The Rust SDK does not have DefaultAzureCredential. Use DeveloperToolsCredential for local development and ManagedIdentityCredential for production.

// Incorrect in Rust: this type does not exist in azure_identity
use azure_identity::DefaultAzureCredential;

Installation

cargo add azure_identity azure_core tokio

If your code uses azure_core types directly, add azure_core to Cargo.toml. If you only use service-crate re-exports, direct azure_core dependency is optional.

Environment Variables

AZURE_TENANT_ID=<your-tenant-id>         # Required for service principal auth
AZURE_CLIENT_ID=<your-client-id>         # Required for service principal or user-assigned managed identity
AZURE_CLIENT_SECRET=<your-client-secret> # Required for ClientSecretCredential

Authentication

DeveloperToolsCredential (Local Development)

Tries Azure CLI then Azure Developer CLI:

use azure_identity::DeveloperToolsCredential;
use azure_security_keyvault_secrets::SecretClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Local dev: DeveloperToolsCredential. Production: use ManagedIdentityCredential.
    let credential = DeveloperToolsCredential::new(None)?;
    let client = SecretClient::new(
        "https://<vault-name>.vault.azure.net/",
        credential.clone(),
        None,
    )?;

    let secret = client.get_secret("secret-name", None).await?.into_model()?;
    println!("Secret: {:?}", secret.value);
    Ok(())
}

Ensure you are logged in:

az login        # Azure CLI
azd auth login  # or Azure Developer CLI
OrderCredentialLogin Command
1AzureCliCredentialaz login
2AzureDeveloperCliCredentialazd auth login

ManagedIdentityCredential (Production)

For Azure-hosted resources (VMs, App Service, Functions, AKS):

use azure_identity::ManagedIdentityCredential;

// System-assigned managed identity
let credential = ManagedIdentityCredential::new(None)?;

ClientSecretCredential (Service Principal)

For CI/CD pipelines and service accounts:

use azure_identity::ClientSecretCredential;

let credential = ClientSecretCredential::new(
    "<tenant-id>",
    "<client-id>",
    "<client-secret>",
    None,
)?;

Credential Types

CredentialUse Case
DeveloperToolsCredentialLocal development — tries CLI tools
ManagedIdentityCredentialAzure VMs, App Service, Functions, AKS
WorkloadIdentityCredentialKubernetes workload identity
ClientSecretCredentialService principal with secret
ClientCertificateCredentialService principal with certificate
AzureCliCredentialDirect Azure CLI auth
AzureDeveloperCliCredentialDirect azd CLI auth
AzurePipelinesCredentialAzure Pipelines service connection
ClientAssertionCredentialCustom assertions (federated identity)

Best Practices

  1. Use cargo add to manage dependencies, never edit Cargo.toml directly. Add and remove Rust SDK dependencies with cargo commands instead of manual manifest edits.
  2. Add azure_core only when importing azure_core types directly. If your code imports azure_core::http::Url, azure_core::http::RequestContent, or azure_core::error::ErrorKind, include azure_core; otherwise a direct dependency is optional.
  3. Use DeveloperToolsCredential for local dev, ManagedIdentityCredential for production — Rust does not provide a single DefaultAzureCredential type
  4. Never hardcode credentials — use environment variables for service principals
  5. Clone credentials — pass credential.clone() when constructing multiple clients; credentials are Arc-wrapped
  6. Reuse clients — clients are thread-safe; create once, share across tasks
  7. Assign RBAC roles — ensure the identity has appropriate roles for the target service (e.g., "Key Vault Secrets User" for secret reads)
  8. Run cargo clippy -- -D warnings when the prompt, eval, or CI expects lint-clean output; Rust trajectory graders can fail on style lints even after compiler errors are fixed
  9. Future-proof #[non_exhaustive] SDK models — when constructing SDK model/options structs, end the initializer with ..Default::default() (add #[allow(clippy::needless_update)]) and use a _ wildcard arm when matching SDK enums, so new service-added fields/variants don't break your build

Reference Links

ResourceLink
API Referencehttps://docs.rs/azure_identity/latest/azure_identity
crates.iohttps://crates.io/crates/azure_identity
Source Codehttps://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/identity/azure_identity

microsoft tarafından daha fazla skill

oss-growth
microsoft
OSS büyüme korsanı kişiliği
agent-framework-azure-ai-py
microsoft
Microsoft Agent Framework Python SDK'sini (agent-framework-azure-ai) kullanarak Azure AI Foundry aracıları oluşturun. AzureAIAgentsProvider ile kalıcı aracılar oluştururken, barındırılan araçları (kod yorumlayıcı, dosya arama, web araması) kullanırken, MCP sunucularını entegre ederken, konuşma iş parçacıklarını yönetirken veya akış yanıtları uygularken kullanın. Fonksiyon araçlarını, yapılandırılmış çıktıları ve çok araçlı aracıları kapsar.
development
airunway-aks-setup
microsoft
Set up AI Runway on AKS — from bare cluster to running model. Covers cluster verification, controller install, GPU assessment, provider setup, and first deployment. WHEN: "setup AI Runway", "onboard AKS cluster", "install AI Runway", "airunway setup", "deploy model to AKS", "GPU inference on AKS", "KAITO setup on AKS", "run LLM on AKS", "vLLM on AKS", "set up model serving on AKS", "AI Runway controller".
devops
appinsights-instrumentation
microsoft
Azure Application Insights ile web uygulamalarını enstrümante etme rehberi. Telemetri desenleri, SDK kurulumu ve yapılandırma referansları sağlar. NE ZAMAN: uygulama nasıl enstrümante edilir, App Insights SDK, telemetri desenleri, App Insights nedir, Application Insights rehberliği, enstrümantasyon örnekleri, APM en iyi uygulamaları.
devops
applicationinsights-web-ts
microsoft
Tarayıcı/web uygulamalarını Application Insights JavaScript SDK'sı (@microsoft/applicationinsights-web) ile izleyin. Gerçek Kullanıcı İzleme (RUM) için kullanın — sayfa görünümleri, tıklamalar, AJAX/fetch bağımlılıkları, özel durumlar, özel olaylar ve arka uç OpenTelemetry izleriyle ilişkilendirilen tarayıcı tarafı GenAI aracı izleri. SDK Loader Script ve npm kurulumunu, çerçeve uzantılarını (React, React Native, Angular), Tıklama Analitiğini, telemetri başlatıcılarını ve tarayıcıdan yayılan aracı/araç/model yayılımları için OTel GenAI anlamsal kurallarını kapsar.
devops
azure-ai-anomalydetector-java
microsoft
Azure AI Anomaly Detector SDK for Java ile anomali tespiti uygulamaları oluşturun. Tek değişkenli/çok değişkenli anomali tespiti, zaman serisi analizi veya yapay zeka destekli izleme uygularken kullanın.
development
azure-ai-language-conversations-py
microsoft
azure-ai-language-conversations Python SDK'sini kullanarak Konuşma Dili Anlama (CLU) uygulayın. ConversationAnalysisClient ile konuşma niyetini ve varlıklarını analiz etmek, NLP özellikleri oluşturmak veya dil anlamayı uygulamalara entegre etmek için kullanın.
development
azure-ai-ml-py
microsoft
Azure Machine Learning SDK v2 for Python. Makine öğrenimi çalışma alanları, işler, modeller, veri kümeleri, bilgi işlem ve iş akışları için kullanın. Tetikleyiciler: "azure-ai-ml", "MLClient", "workspace", "model registry", "training jobs", "datasets".
development