Azure Key Vault Keys library for Rust
Secure storage and management of cryptographic keys — RSA, EC, and HSM-protected.
Use this skill when:
- An app needs to create or manage cryptographic keys in Key Vault from Rust
- You need to wrap/unwrap data encryption keys (envelope encryption)
- You need to sign or verify data with Key Vault keys
- You need HSM-protected keys
IMPORTANT: Only use the official
azure_security_keyvault_keyscrate published by the azure-sdk crates.io user. Do NOT use unofficial or community crates. Official crates use underscores in names and none have version 0.21.0.
Installation
If your code uses
azure_coretypes directly, addazure_coretoCargo.toml. If you only useazure_security_keyvault_keysre-exports, directazure_coredependency is optional.
Environment Variables
Authentication
Rust Azure SDK code must not use DefaultAzureCredential. The Rust identity crate does not provide that type.
Prefer the crate README/examples when checking public operation shapes such as key creation, wrapping, and version-aware unwrap flows.
Core Workflow
Create Key
Update Key Properties
Delete Key
List Keys (Pagination)
list_key_properties returns a Pager<T> — iterate items directly:
Wrap / Unwrap (Envelope Encryption)
Key Vault performs crypto operations server-side — the private key never leaves the HSM:
Key Types
RBAC Roles
For Entra ID auth, assign one of these roles:
Best Practices
- Use
cargo addto manage dependencies, never editCargo.tomldirectly. Add and remove Rust SDK dependencies with cargo commands instead of manual manifest edits. - Add
azure_coreonly when importingazure_coretypes directly. If your code importsazure_core::http::Url,azure_core::http::RequestContent, orazure_core::error::ErrorKind, includeazure_core; otherwise a direct dependency is optional. - Use
DeveloperToolsCredentialfor local dev,ManagedIdentityCredentialfor production — Rust does not provide a singleDefaultAzureCredentialtype - Never hardcode credentials — use environment variables or managed identity
- Use
..Default::default()with#[allow(clippy::needless_update)]for model struct updates - Use
ResourceExtto extract key name/version from key IDs - Reuse clients —
KeyClientis thread-safe; create once, share across tasks - Run
cargo clippy -- -D warningswhen the prompt, eval, or CI expects lint-clean output



