Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify example blob_05_default_credential.rs #1373

Merged
merged 3 commits into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions sdk/storage_blobs/examples/blob_05_default_credential.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#[macro_use]
extern crate log;

use std::sync::Arc;

use azure_core::{
auth::TokenCredential,
error::{ErrorKind, ResultExt},
};
use azure_identity::DefaultAzureCredential;
use azure_storage::prelude::*;
use azure_storage_blobs::prelude::*;

#[tokio::main]
Expand All @@ -24,11 +25,7 @@ async fn main() -> azure_core::Result<()> {
.nth(3)
.expect("please specify the blob name as third command line parameter");

let bearer_token = DefaultAzureCredential::default()
.get_token("https://storage.azure.com/")
.await?;

let storage_credentials = StorageCredentials::BearerToken(bearer_token.token.secret().into());
let storage_credentials: Arc<dyn TokenCredential> = Arc::new(DefaultAzureCredential::default());
let blob_client = BlobServiceClient::new(account, storage_credentials)
.container_client(&container)
.blob_client(&blob);
Expand Down