{"id":3334,"date":"2025-02-19T10:19:05","date_gmt":"2025-02-19T18:19:05","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-sdk\/?p=3334"},"modified":"2025-02-27T10:32:49","modified_gmt":"2025-02-27T18:32:49","slug":"rust-in-time-announcing-the-azure-sdk-for-rust-beta","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-sdk\/rust-in-time-announcing-the-azure-sdk-for-rust-beta\/","title":{"rendered":"Rust in time! Announcing the Azure SDK for Rust Beta. \ud83c\udf89"},"content":{"rendered":"<p>We&#8217;re thrilled to announce the first beta releases for the Official Azure SDK for Rust! \ud83c\udf89 These releases include libraries for Identity, Key Vault secrets &amp; keys, Event Hubs, and Cosmos DB. These libraries are designed to provide a seamless and idiomatic experience for Rust developers working with Azure services.<\/p>\n<h2>Why Rust? \ud83e\udd80<\/h2>\n<p>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.<\/p>\n<p>Rust&#8217;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&#8217;s modern syntax and tooling make it a pleasure to work with, attracting a vibrant and enthusiastic developer community.<\/p>\n<p>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&#8217;s the power of Rust!<\/p>\n<h2>Beta libraries \ud83d\udcda<\/h2>\n<p>The following libraries are included in this beta release:<\/p>\n<table>\n<thead>\n<tr>\n<th>Service<\/th>\n<th>Crates \ud83d\udce6<\/th>\n<th>Source Code<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Identity<\/td>\n<td><a href=\"https:\/\/crates.io\/crates\/azure_identity\"><code>azure_identity<\/code><\/a><\/td>\n<td><a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-rust\/tree\/main\/sdk\/identity\/azure_identity\">GitHub<\/a><\/td>\n<\/tr>\n<tr>\n<td>Key Vault secrets<\/td>\n<td><a href=\"https:\/\/crates.io\/crates\/azure_security_keyvault_secrets\"><code>azure_security_keyvault_secrets<\/code><\/a><\/td>\n<td><a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-rust\/tree\/main\/sdk\/keyvault\/azure_security_keyvault_secrets\">GitHub<\/a><\/td>\n<\/tr>\n<tr>\n<td>Key Vault keys<\/td>\n<td><a href=\"https:\/\/crates.io\/crates\/azure_security_keyvault_keys\"><code>azure_security_keyvault_keys<\/code><\/a><\/td>\n<td><a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-rust\/tree\/main\/sdk\/keyvault\/azure_security_keyvault_keys\">GitHub<\/a><\/td>\n<\/tr>\n<tr>\n<td>Event Hubs<\/td>\n<td><a href=\"https:\/\/crates.io\/crates\/azure_messaging_eventhubs\"><code>azure_messaging_eventhubs<\/code><\/a><\/td>\n<td><a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-rust\/tree\/main\/sdk\/eventhubs\/azure_messaging_eventhubs\">GitHub<\/a><\/td>\n<\/tr>\n<tr>\n<td>Cosmos DB<\/td>\n<td><a href=\"https:\/\/crates.io\/crates\/azure_data_cosmos\"><code>azure_data_cosmos<\/code><\/a><\/td>\n<td><a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-rust\/tree\/main\/sdk\/cosmos\/azure_data_cosmos\">GitHub<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Get started \ud83d\ude80<\/h2>\n<p>To get started with the Azure SDK for Rust, follow these steps:<\/p>\n<h3>1. Add dependencies<\/h3>\n<p>Add the desired Azure SDK crates to your project using the <code>cargo add<\/code> command. For example, to use the Identity and Key Vault Secrets libraries, run the following command:<\/p>\n<pre><code class=\"language-bash\">cargo add azure_identity azure_security_keyvault_secrets tokio --features tokio\/full<\/code><\/pre>\n<h3>2. Import the libraries<\/h3>\n<p>In your Rust code, import the necessary modules from the Azure SDK crates. For example:<\/p>\n<pre><code class=\"language-rust\">use azure_identity::DefaultAzureCredential;\nuse azure_security_keyvault_secrets::{\n    models::SecretSetParameters, ResourceExt as _, SecretClient,\n};<\/code><\/pre>\n<h3>3. Create a new secret client<\/h3>\n<p>First, create a new secret client using the <code>DefaultAzureCredential<\/code>:<\/p>\n<pre><code class=\"language-rust\">#[tokio::main]\nasync fn main() -&gt; Result&lt;(), Box&lt;dyn std::error::Error&gt;&gt; {\n    \/\/ Create a credential using DefaultAzureCredential\n    let credential = DefaultAzureCredential::new()?;\n    \/\/ Initialize the SecretClient with the Key Vault URL and credential\n    let client = SecretClient::new(\n        \"https:\/\/your-key-vault-name.vault.azure.net\/\",\n        credential.clone(),\n        None,\n    )?;\n\n    \/\/ Additional code will go here...\n\n    Ok(())\n}<\/code><\/pre>\n<h3>4. Create a new secret<\/h3>\n<p>Next, create a new secret using the secret client:<\/p>\n<pre><code class=\"language-rust\">\/\/ Previous code above...\n    \/\/ Set parameters for the new secret\n     let secret_set_parameters = SecretSetParameters {\n        value: Some(\"secret-value\".into()),\n        ..Default::default()\n    };\n\n    \/\/ Create the new secret in Key Vault\n    let secret = client\n        .set_secret(\"secret-name\", secret_set_parameters.try_into()?, None)\n        .await?\n        .into_body()\n        .await?;<\/code><\/pre>\n<h3>5. Retrieve a secret<\/h3>\n<p>Finally, retrieve a secret using the secret client:<\/p>\n<pre><code class=\"language-rust\">\/\/ Previous code above...\n    \/\/ Get the version of the created secret\n    let version = secret.resource_id()?.version.unwrap_or_default();\n\n    \/\/ Retrieve the secret from Key Vault\n    let secret = client\n        .get_secret(\"secret-name\", version.as_ref(), None)\n        .await?\n        .into_body()\n        .await?;\n    \/\/ Print the value of the retrieved secret\n    println!(\"{:?}\", secret.value);<\/code><\/pre>\n<p>For more detailed documentation, code samples, and installation instructions, visit our <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-rust\">GitHub repository<\/a>.<\/p>\n<h2>Future plans \ud83d\udd2e<\/h2>\n<p>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.<\/p>\n<p>We also plan on a few changes that should simplify usage without sacrificing versatility:  <\/p>\n<ul>\n<li>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.  <\/li>\n<li>Deserialize arrays as empty <code>Vec&lt;T&gt;<\/code> in most cases to simplify code.  <\/li>\n<\/ul>\n<h2>Feedback \ud83d\udcac<\/h2>\n<p>We value your feedback and would love to hear about your experiences with the Azure SDK for Rust. Head over to our <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-rust\/issues\">GitHub issues page<\/a> 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.<\/p>\n<p>Don&#8217;t miss the chance to make a difference and join the conversation!<\/p>\n<p>We can&#8217;t wait to hear from you and see what amazing things you build with Rust and Azure! \ud83d\ude80<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Announcing the first beta release of the Azure SDK for Rust. This release includes libraries for Identity, Key Vault secrets &amp; keys, Event Hubs, and Cosmos DB.<\/p>\n","protected":false},"author":104000,"featured_media":3335,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[750,937,785,158,936,935],"class_list":["post-3334","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-sdk","tag-azure-sdk","tag-cosmos-db","tag-event-hubs","tag-identity","tag-key-vault","tag-rust"],"acf":[],"blog_post_summary":"<p>Announcing the first beta release of the Azure SDK for Rust. This release includes libraries for Identity, Key Vault secrets &amp; keys, Event Hubs, and Cosmos DB.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts\/3334","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/users\/104000"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/comments?post=3334"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts\/3334\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/media\/3335"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/media?parent=3334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/categories?post=3334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/tags?post=3334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}