Created
September 25, 2019 10:52
-
-
Save ctaggart/8b86ce938943443ebd85f4a7aa74ca4f to your computer and use it in GitHub Desktop.
create_blobs.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use azure_sdk_core::prelude::*; | |
use azure_sdk_storage_blob::prelude::*; | |
use azure_sdk_storage_core::prelude::*; | |
use futures::future::*; | |
use std::error::Error; | |
use tokio_core::reactor::Core; | |
fn main() { | |
code().unwrap(); | |
} | |
fn code() -> Result<(), Box<dyn Error>> { | |
let account = std::env::var("STORAGE_ACCOUNT").expect("Set env variable STORAGE_ACCOUNT first!"); | |
let master_key = std::env::var("STORAGE_MASTER_KEY").expect("Set env variable STORAGE_MASTER_KEY first!"); | |
let container = std::env::args() | |
.nth(1) | |
.expect("please specify container name as command line parameter"); | |
let mut core = Core::new()?; | |
let client = Client::new(&account, &master_key)?; | |
let data = b"something"; | |
let digest = md5::compute(&data[..]); | |
for i in 0..5050 { | |
println!("{}", i); | |
let blob_name = format!("{}.txt", i); | |
let future = client | |
.put_block_blob() | |
.with_container_name(&container) | |
.with_blob_name(&blob_name) | |
.with_content_type("text/plain") | |
.with_body(&data[..]) | |
.with_content_md5(&digest[..]) | |
.finalize(); | |
core.run(future)?; | |
}; | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment