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".
Instalación
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
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".
license
MIT
metadata
{"author":"Microsoft","package":"azure_identity"}
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.
Installation
cargo add azure_identity tokio
Do not add azure_core directly to Cargo.toml. It is re-exported by service crates.
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]asyncfnmain() ->Result<(), Box<dyn std::error::Error>> {
// Local dev: DeveloperToolsCredential. Production: use ManagedIdentityCredential.letcredential = DeveloperToolsCredential::new(None)?;
letclient = SecretClient::new(
"https://<vault-name>.vault.azure.net/",
credential.clone(),
None,
)?;
letsecret = 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
Order
Credential
Login Command
1
AzureCliCredential
az login
2
AzureDeveloperCliCredential
azd auth login
ManagedIdentityCredential (Production)
For Azure-hosted resources (VMs, App Service, Functions, AKS):
use azure_identity::ClientSecretCredential;
letcredential = ClientSecretCredential::new(
"<tenant-id>",
"<client-id>",
"<client-secret>",
None,
)?;
Credential Types
Credential
Use Case
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)
Best Practices
Use DeveloperToolsCredential for local development and ManagedIdentityCredential for production. The Rust SDK does not support DefaultAzureCredential, so explicitly use the appropriate credential in each environment.
Never hardcode credentials — use environment variables or managed identity for all authentication
Assign appropriate RBAC roles for Entra ID auth. For production authentication using Entra ID, ensure the identity has the necessary RBAC role assigned for the target service (e.g., "Key Vault Secrets User" for secret reads).
Always verify package versions using crates.io. Before using a package, check its version on crates.io to ensure you are using a stable and supported release.
Clone credentials — pass credential.clone() when constructing multiple clients; credentials are Arc-wrapped and thread-safe
Reuse clients — clients are thread-safe; create once, share across tasks