Rust
Rust
Configure Azure Storage Shared Key Authentication
See more REST Examples
Demonstrates Rest.SetAuthAzureStorage, which associates an AuthAzureStorage provider so Chilkat automatically adds a Shared Key Authorization header. The provider supplies the account name, base64 account key, service, and scheme.
Background. Azure Storage Shared Key authorization signs each request with the account access key. The provider also manages the
x-ms-version header required by the storage REST API.Chilkat Rust Downloads
let rest = chilkat::Rest::new();
let b_tls = true;
let b_auto_reconnect = true;
if rest.connect("example.com", 443, b_tls, b_auto_reconnect).is_err() {
println!("{}", rest.last_error_text());
return;
}
// Configure Azure Storage Shared Key authentication. Provide the account name, base64 account
// access key, service, and (optionally) the x-ms-version.
let az_auth = chilkat::AuthAzureStorage::new();
az_auth.set_account("myStorageAccount");
// Normally you would not hard-code secrets in source. You should instead obtain them from an
// interactive prompt, environment variable, or a secrets vault.
az_auth.set_access_key("BASE64_ACCOUNT_ACCESS_KEY");
az_auth.set_scheme("SharedKey");
az_auth.set_service("Blob");
az_auth.set_x_ms_version("2021-08-06");
// Associate the provider so Chilkat automatically adds the Shared Key Authorization header.
if rest.set_auth_azure_storage(&az_auth).is_err() {
println!("{}", rest.last_error_text());
return;
}
let Ok(response_text) = rest.full_request_no_body("GET", "/mycontainer?restype=container&comp=list") else {
println!("{}", rest.last_error_text());
return;
};
println!("{}", response_text);