Skip to content

Instantly share code, notes, and snippets.

@ctaggart
Created September 25, 2019 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctaggart/8b86ce938943443ebd85f4a7aa74ca4f to your computer and use it in GitHub Desktop.
Save ctaggart/8b86ce938943443ebd85f4a7aa74ca4f to your computer and use it in GitHub Desktop.
create_blobs.rs
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