azure_storage

Struct StorageCredentials

source
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

source

pub fn access_key<A, K>(account: A, key: K) -> Self
where A: Into<String>, K: Into<Secret>,

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

source

pub fn sas_token<S>(token: S) -> Result<Self>
where S: AsRef<str>,

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.

source

pub fn bearer_token<T>(token: T) -> Self
where T: Into<Secret>,

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

source

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

source

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

source

pub fn emulator() -> Self

Create an Access Key credential for use with the Azure Storage emulator

source

pub async fn replace(&self, other: Self) -> Result<()>

Replace the current credentials with new credentials

This method is useful for updating credentials that are used by multiple clients at once.

Trait Implementations§

source§

impl Clone for StorageCredentials

source§

fn clone(&self) -> StorageCredentials

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for StorageCredentials

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Arc<dyn TokenCredential>> for StorageCredentials

source§

fn from(cred: Arc<dyn TokenCredential>) -> Self

Converts to this type from the input type.
source§

impl TryFrom<&Url> for StorageCredentials

source§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(value: &Url) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T