We’re thrilled to announce the first beta releases for the Official Azure SDK for Rust! 🎉 These releases include libraries for Identity, Key Vault secrets & keys, Event Hubs, and Cosmos DB. These libraries are designed to provide a seamless and idiomatic experience for Rust developers working with Azure services.
Why Rust? 🦀
We decided to create an official Azure SDK for Rust due to the growing interest in the Rust programming language, both externally and within Microsoft. Rust is known for its performance, reliability, and memory safety, making it an excellent choice for systems programming and applications that require high performance and low-level control.
Rust’s strong type system and ownership model help prevent common programming errors such as null pointer dereferencing and buffer overflows, leading to more secure and stable code. Additionally, Rust’s modern syntax and tooling make it a pleasure to work with, attracting a vibrant and enthusiastic developer community.
By providing an official Azure SDK for Rust, we aim to empower Rust developers to build robust and efficient applications with Azure, using the full potential of the Rust language. Imagine building high-performance applications with the confidence that your code is secure and reliable. That’s the power of Rust!
Beta libraries 📚
The following libraries are included in this beta release:
Service | Crates 📦 | Source Code |
---|---|---|
Identity | azure_identity |
GitHub |
Key Vault secrets | azure_security_keyvault_secrets |
GitHub |
Key Vault keys | azure_security_keyvault_keys |
GitHub |
Event Hubs | azure_messaging_eventhubs |
GitHub |
Cosmos DB | azure_data_cosmos (available on February 26) |
GitHub |
Get started 🚀
To get started with the Azure SDK for Rust, follow these steps:
1. Add dependencies
Add the desired Azure SDK crates to your project using the cargo add
command. For example, to use the Identity and Key Vault Secrets libraries, run the following command:
cargo add azure_identity azure_security_keyvault_secrets tokio --features tokio/full
2. Import the libraries
In your Rust code, import the necessary modules from the Azure SDK crates. For example:
use azure_identity::DefaultAzureCredential;
use azure_security_keyvault_secrets::{
models::SecretSetParameters, ResourceExt as _, SecretClient,
};
3. Create a new secret client
First, create a new secret client using the DefaultAzureCredential
:
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a credential using DefaultAzureCredential
let credential = DefaultAzureCredential::new()?;
// Initialize the SecretClient with the Key Vault URL and credential
let client = SecretClient::new(
"https://your-key-vault-name.vault.azure.net/",
credential.clone(),
None,
)?;
// Additional code will go here...
Ok(())
}
4. Create a new secret
Next, create a new secret using the secret client:
// Previous code above...
// Set parameters for the new secret
let secret_set_parameters = SecretSetParameters {
value: Some("secret-value".into()),
..Default::default()
};
// Create the new secret in Key Vault
let secret = client
.set_secret("secret-name", secret_set_parameters.try_into()?, None)
.await?
.into_body()
.await?;
5. Retrieve a secret
Finally, retrieve a secret using the secret client:
// Previous code above...
// Get the version of the created secret
let version = secret.resource_id()?.version.unwrap_or_default();
// Retrieve the secret from Key Vault
let secret = client
.get_secret("secret-name", version.as_ref(), None)
.await?
.into_body()
.await?;
// Print the value of the retrieved secret
println!("{:?}", secret.value);
For more detailed documentation, code samples, and installation instructions, visit our GitHub repository.
Future plans 🔮
Our team is committed to expanding the Azure SDK for Rust by adding more Azure service libraries and refining these announced libraries. We aim to stabilize these libraries and provide a robust, reliable, and user-friendly experience for Rust developers.
We also plan on a few changes that should simplify usage without sacrificing versatility:
- Buffer the entire response in the pipeline to make sure all built-in and developer-specified policies apply, like the retry policy on some failures.
- Deserialize arrays as empty
Vec<T>
in most cases to simplify code.
Feedback 💬
We value your feedback and would love to hear about your experiences with the Azure SDK for Rust. Head over to our GitHub issues page to share your thoughts, report any issues, and contribute to the project. Your input will help us improve and shape the future of the SDK.
Don’t miss the chance to make a difference and join the conversation!
We can’t wait to hear from you and see what amazing things you build with Rust and Azure! 🚀
Love it