#sdk #azure #rest #iot #cloud

azure_identity

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

10 breaking releases

new 0.11.0 Mar 17, 2023
0.9.0 Dec 16, 2022
0.8.0 Nov 30, 2022
0.4.0 Jun 16, 2022
0.1.1 Jan 25, 2022

#13 in Authentication

Download history 1452/week @ 2022-11-28 1516/week @ 2022-12-05 1415/week @ 2022-12-12 980/week @ 2022-12-19 591/week @ 2022-12-26 1387/week @ 2023-01-02 1508/week @ 2023-01-09 1382/week @ 2023-01-16 1872/week @ 2023-01-23 1855/week @ 2023-01-30 2135/week @ 2023-02-06 2361/week @ 2023-02-13 2430/week @ 2023-02-20 1957/week @ 2023-02-27 1655/week @ 2023-03-06 1450/week @ 2023-03-13

7,541 downloads per month
Used in 5 crates

MIT license

260KB
6K 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–19MB
~373K SLoC