pub struct StorageCredentials(pub Arc<RwLock<StorageCredentialsInner>>);
Expand description
Credentials for accessing a storage account.
§Example
The best way to create StorageCredentials
is through use of one of the helper functions.
For example, to use an account name and access key:
azure_storage::StorageCredentials::access_key("my_account", azure_core::auth::Secret::new("SOMEACCESSKEY"));
Tuple Fields§
§0: Arc<RwLock<StorageCredentialsInner>>
Implementations§
source§impl StorageCredentials
impl StorageCredentials
sourcepub fn access_key<A, K>(account: A, key: K) -> Self
pub fn access_key<A, K>(account: A, key: K) -> Self
Create an Access Key based credential
When you create a storage account, Azure generates two 512-bit storage account access keys for that account. These keys can be used to authorize access to data in your storage account via Shared Key authorization.
ref: https://docs.microsoft.com/azure/storage/common/storage-account-keys-manage
sourcepub fn sas_token<S>(token: S) -> Result<Self>
pub fn sas_token<S>(token: S) -> Result<Self>
Create a Shared Access Signature (SAS) token based credential
SAS tokens are HTTP query strings that provide delegated access to resources in a storage account with granular control over how the client can access data in the account.
sourcepub fn bearer_token<T>(token: T) -> Self
pub fn bearer_token<T>(token: T) -> Self
Create an Bearer Token based credential
Azure Storage accepts OAuth 2.0 access tokens from the Azure AD tenant associated with the subscription that contains the storage account.
While StorageCredentials::TokenCredential
is the preferred way to
manage access tokens, this method is provided for manual management of
Oauth2 tokens.
ref: https://docs.microsoft.com/rest/api/storageservices/authorize-with-azure-active-directory
sourcepub fn token_credential(credential: Arc<dyn TokenCredential>) -> Self
pub fn token_credential(credential: Arc<dyn TokenCredential>) -> Self
Create a TokenCredential
based credential
Azure Storage accepts OAuth 2.0 access tokens from the Azure AD tenant associated with the subscription that contains the storage account.
Token Credentials can be created and automatically updated using
azure_identity
.
use azure_storage::prelude::*;
let credential = azure_identity::create_credential().unwrap();
let storage_credentials = StorageCredentials::token_credential(credential);
ref: https://docs.microsoft.com/rest/api/storageservices/authorize-with-azure-active-directory
sourcepub fn anonymous() -> Self
pub fn anonymous() -> Self
Create an anonymous credential
Azure Storage supports optional anonymous public read access for containers and blobs. By default, anonymous access to data in a storage account data is not permitted. Unless anonymous access is explicitly enabled, all requests to a container and its blobs must be authorized. When a container’s public access level setting is configured to permit anonymous access, clients can read data in that container without authorizing the request.
ref: https://docs.microsoft.com/azure/storage/blobs/anonymous-read-access-configure
Trait Implementations§
source§impl Clone for StorageCredentials
impl Clone for StorageCredentials
source§fn clone(&self) -> StorageCredentials
fn clone(&self) -> StorageCredentials
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for StorageCredentials
impl Debug for StorageCredentials
source§impl From<Arc<dyn TokenCredential>> for StorageCredentials
impl From<Arc<dyn TokenCredential>> for StorageCredentials
source§fn from(cred: Arc<dyn TokenCredential>) -> Self
fn from(cred: Arc<dyn TokenCredential>) -> Self
Auto Trait Implementations§
impl Freeze for StorageCredentials
impl !RefUnwindSafe for StorageCredentials
impl Send for StorageCredentials
impl Sync for StorageCredentials
impl Unpin for StorageCredentials
impl !UnwindSafe for StorageCredentials
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)