#sdk #azure #rest #iot #cloud

azure_identity

Rust wrappers around Microsoft Azure REST APIs - Azure identity helper crate

16 breaking releases

0.17.0 Nov 3, 2023
0.16.0 Sep 28, 2023
0.13.0 Jun 28, 2023
0.11.0 Mar 17, 2023
0.1.1 Jan 25, 2022

#2 in #azure

Download history 6091/week @ 2023-08-14 8269/week @ 2023-08-21 7553/week @ 2023-08-28 4793/week @ 2023-09-04 5266/week @ 2023-09-11 7315/week @ 2023-09-18 8230/week @ 2023-09-25 8800/week @ 2023-10-02 12108/week @ 2023-10-09 23208/week @ 2023-10-16 22055/week @ 2023-10-23 23440/week @ 2023-10-30 15349/week @ 2023-11-06 9757/week @ 2023-11-13 8019/week @ 2023-11-20 12939/week @ 2023-11-27

46,641 downloads per month
Used in 10 crates

MIT license

290KB
6.5K SLoC

azure_identity

Azure Identity crate for the unofficial Microsoft Azure SDK for Rust. This crate is part of a collection of crates: for more information please refer to https://github.com/azure/azure-sdk-for-rust. This crate provides mechanisms for several ways to authenticate against Azure

For example, to authenticate using the recommended DefaultAzureCredential, you can do the following:

use azure_core::auth::TokenCredential;
use azure_identity::{DefaultAzureCredential};
use url::Url;

use std::env;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let credential = DefaultAzureCredential::default();
    let response = credential
        .get_token("https://management.azure.com")
        .await?;

    let subscription_id = env::var("AZURE_SUBSCRIPTION_ID")?;
    let url = Url::parse(&format!(
        "https://management.azure.com/subscriptions/{}/providers/Microsoft.Storage/storageAccounts?api-version=2019-06-01",
        subscription_id))?;
    let response = reqwest::Client::new()
        .get(url)
        .header("Authorization", format!("Bearer {}", response.token.secret()))
        .send()
        .await?
        .text()
        .await?;

    println!("{:?}", response);
    Ok(())
}

The supported authentication flows are:

This crate also includes utilities for handling refresh tokens and accessing token credentials from many different sources.

License: MIT

Dependencies

~8–24MB
~383K SLoC