Skip to main content

BlobClient

Struct BlobClient 

Source
pub struct BlobClient { /* private fields */ }

Implementations§

Source§

impl BlobClient

Source

pub fn new( blob_url: Url, credential: Option<Arc<dyn TokenCredential>>, options: Option<BlobClientOptions>, ) -> Result<Self>

Creates a new BlobClient from a blob URL.

§Arguments
  • blob_url - The full URL of the blob, for example https://myaccount.blob.core.windows.net/mycontainer/myblob. The caller is responsible for percent-encoding the URL correctly; it will be used as-is.
  • credential - An optional implementation of TokenCredential that can provide an Entra ID token to use when authenticating.
  • options - Optional configuration for the client.
Source

pub fn append_blob_client(&self) -> AppendBlobClient

Returns a new instance of AppendBlobClient.

Source

pub fn block_blob_client(&self) -> BlockBlobClient

Returns a new instance of BlockBlobClient.

Source

pub fn page_blob_client(&self) -> PageBlobClient

Returns a new instance of PageBlobClient.

Source

pub fn url(&self) -> &Url

Gets the URL of the resource this client is configured for.

Source

pub fn with_version(&self, version_id: &str) -> Result<Self>

Creates a new BlobClient targeting a specific blob version.

§Arguments
  • version_id - The version ID of the blob to target.
Source

pub fn with_snapshot(&self, snapshot: &str) -> Result<Self>

Creates a new BlobClient targeting a specific blob snapshot.

§Arguments
  • snapshot - The snapshot ID of the blob to target.
Source

pub async fn download( &self, options: Option<BlobClientDownloadOptions<'_>>, ) -> Result<BlobClientDownloadResult>

Downloads a blob and its contents from the service.

This operation performs a managed (multi-part) download, splitting the blob into parallel range requests for better performance on large blobs. The returned BlobClientDownloadResult::body contains the complete blob data, while BlobClientDownloadResult::properties and BlobClientDownloadResult::headers reflect only the initial response’s metadata and properties.

If the streamed bytes of this blob are to be collected into contiguous memory, consider instead calling BlobClient::download_into with a pre-allocated buffer to avoid unnecessary copies and allocations.

§Arguments
  • options - Optional configuration for the request.
§Notes

By default, storage clients create their HTTP transport via azure_core::http::new_http_client() with automatic decompression disabled. If you set a custom transport in BlobClientOptions without also disabling automatic decompression, partitioned downloads may not succeed.

Source

pub async fn download_into( &self, buffer: &mut [u8], options: Option<BlobClientDownloadOptions<'_>>, ) -> Result<BlobClientDownloadIntoResult>

Downloads a blob and its contents from the service.

This operation performs a managed (multi-part) download, splitting the blob into parallel range requests for better performance on large blobs. The downloaded bytes are written directly into the provided buffer.

§Arguments
  • buffer - Destination buffer to write the downloaded blob data into.
  • options - Optional configuration for the request.
§Notes

By default, storage clients create their HTTP transport via azure_core::http::new_http_client() with automatic decompression disabled. If you set a custom transport in BlobClientOptions without also disabling automatic decompression, partitioned downloads may not succeed.

Source

pub async fn upload( &self, content: RequestContent<Bytes, NoFormat>, options: Option<BlobClientUploadOptions<'_>>, ) -> Result<BlobClientUploadResult>

Uploads content to a block blob, overwriting any existing blob by default.

Updating an existing block blob overwrites any existing metadata on the blob. Use BlobClientUploadOptions::if_not_exists() to fail instead of overwriting. To perform a partial update of the content of a block blob, use BlockBlobClient::stage_block() and BlockBlobClient::commit_block_list() directly.

§Arguments
  • content - The content to upload.
  • options - Optional parameters for the request.
Source

pub async fn exists(&self) -> Result<bool>

Checks if the blob exists.

Returns true if the blob exists, false if the blob does not exist, and propagates all other errors.

Source§

impl BlobClient

Source

pub async fn abort_copy( &self, copy_id: &str, options: Option<BlobClientAbortCopyOptions<'_>>, ) -> Result<Response<(), NoFormat>>

Aborts a pending asynchronous copy operation and leaves a destination blob with zero length and full metadata.

§Arguments
  • copy_id - The ID of the copy to be aborted.
  • options - Optional parameters for the request.
Source

pub async fn acquire_lease( &self, duration: i32, options: Option<BlobClientAcquireLeaseOptions<'_>>, ) -> Result<Response<BlobClientAcquireLeaseResult, NoFormat>>

Requests a new lease on the specified blob.

§Arguments
  • duration - Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds.
  • options - Optional parameters for the request.
§Response Headers

The returned Response implements the BlobClientAcquireLeaseResultHeaders trait, which provides access to response headers. For example:

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobClientAcquireLeaseResult, BlobClientAcquireLeaseResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobClientAcquireLeaseResult, NoFormat> = unimplemented!();
    // Access response headers
    if let Some(etag) = response.etag()? {
        println!("etag: {:?}", etag);
    }
    if let Some(last_modified) = response.last_modified()? {
        println!("last-modified: {:?}", last_modified);
    }
    if let Some(lease_id) = response.lease_id()? {
        println!("x-ms-lease-id: {:?}", lease_id);
    }
    Ok(())
}
§Available headers
Source

pub async fn break_lease( &self, options: Option<BlobClientBreakLeaseOptions<'_>>, ) -> Result<Response<BlobClientBreakLeaseResult, NoFormat>>

Ends a lease and ensures that another client can’t acquire a new lease until the current lease period has expired.

§Arguments
  • options - Optional parameters for the request.
§Response Headers

The returned Response implements the BlobClientBreakLeaseResultHeaders trait, which provides access to response headers. For example:

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobClientBreakLeaseResult, BlobClientBreakLeaseResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobClientBreakLeaseResult, NoFormat> = unimplemented!();
    // Access response headers
    if let Some(etag) = response.etag()? {
        println!("etag: {:?}", etag);
    }
    if let Some(last_modified) = response.last_modified()? {
        println!("last-modified: {:?}", last_modified);
    }
    if let Some(lease_time) = response.lease_time()? {
        println!("x-ms-lease-time: {:?}", lease_time);
    }
    Ok(())
}
§Available headers
Source

pub async fn change_lease( &self, lease_id: String, proposed_lease_id: String, options: Option<BlobClientChangeLeaseOptions<'_>>, ) -> Result<Response<BlobClientChangeLeaseResult, NoFormat>>

Change the ID of an existing lease.

§Arguments
  • lease_id - A lease ID for the resource. The resource must have an active lease and the lease ID must match.
  • proposed_lease_id - The proposed lease ID for the lease.
  • options - Optional parameters for the request.
§Response Headers

The returned Response implements the BlobClientChangeLeaseResultHeaders trait, which provides access to response headers. For example:

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobClientChangeLeaseResult, BlobClientChangeLeaseResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobClientChangeLeaseResult, NoFormat> = unimplemented!();
    // Access response headers
    if let Some(etag) = response.etag()? {
        println!("etag: {:?}", etag);
    }
    if let Some(last_modified) = response.last_modified()? {
        println!("last-modified: {:?}", last_modified);
    }
    if let Some(lease_id) = response.lease_id()? {
        println!("x-ms-lease-id: {:?}", lease_id);
    }
    Ok(())
}
§Available headers
Source

pub async fn create_snapshot( &self, options: Option<BlobClientCreateSnapshotOptions<'_>>, ) -> Result<Response<BlobClientCreateSnapshotResult, NoFormat>>

Creates a read-only snapshot of the specified blob.

§Arguments
  • options - Optional parameters for the request.
§Response Headers

The returned Response implements the BlobClientCreateSnapshotResultHeaders trait, which provides access to response headers. For example:

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobClientCreateSnapshotResult, BlobClientCreateSnapshotResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobClientCreateSnapshotResult, NoFormat> = unimplemented!();
    // Access response headers
    if let Some(etag) = response.etag()? {
        println!("etag: {:?}", etag);
    }
    if let Some(last_modified) = response.last_modified()? {
        println!("last-modified: {:?}", last_modified);
    }
    if let Some(is_server_encrypted) = response.is_server_encrypted()? {
        println!("x-ms-request-server-encrypted: {:?}", is_server_encrypted);
    }
    Ok(())
}
§Available headers
Source

pub async fn delete( &self, options: Option<BlobClientDeleteOptions<'_>>, ) -> Result<Response<(), NoFormat>>

Deletes the specified blob. If blob soft delete is enabled, the blob is marked for deletion and can be recovered until the retention period expires.

§Arguments
  • options - Optional parameters for the request.
Source

pub async fn delete_immutability_policy( &self, options: Option<BlobClientDeleteImmutabilityPolicyOptions<'_>>, ) -> Result<Response<(), NoFormat>>

Deletes the immutability policy on the specified blob.

§Arguments
  • options - Optional parameters for the request.
Source

pub async fn get_account_info( &self, options: Option<BlobClientGetAccountInfoOptions<'_>>, ) -> Result<Response<BlobClientGetAccountInfoResult, NoFormat>>

Returns information about the storage account.

§Arguments
  • options - Optional parameters for the request.
§Response Headers

The returned Response implements the BlobClientGetAccountInfoResultHeaders trait, which provides access to response headers. For example:

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobClientGetAccountInfoResult, BlobClientGetAccountInfoResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobClientGetAccountInfoResult, NoFormat> = unimplemented!();
    // Access response headers
    if let Some(account_kind) = response.account_kind()? {
        println!("x-ms-account-kind: {:?}", account_kind);
    }
    if let Some(is_hierarchical_namespace_enabled) = response.is_hierarchical_namespace_enabled()? {
        println!("x-ms-is-hns-enabled: {:?}", is_hierarchical_namespace_enabled);
    }
    if let Some(sku_name) = response.sku_name()? {
        println!("x-ms-sku-name: {:?}", sku_name);
    }
    Ok(())
}
§Available headers
Source

pub async fn get_properties( &self, options: Option<BlobClientGetPropertiesOptions<'_>>, ) -> Result<Response<BlobClientGetPropertiesResult, NoFormat>>

Returns all user-defined metadata, standard HTTP properties, and system properties for the specified blob. It does not return the content of the blob.

§Arguments
  • options - Optional parameters for the request.
§Response Headers

The returned Response implements the BlobClientGetPropertiesResultHeaders trait, which provides access to response headers. For example:

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobClientGetPropertiesResult, BlobClientGetPropertiesResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobClientGetPropertiesResult, NoFormat> = unimplemented!();
    // Access response headers
    if let Some(cache_control) = response.cache_control()? {
        println!("cache-control: {:?}", cache_control);
    }
    if let Some(content_disposition) = response.content_disposition()? {
        println!("content-disposition: {:?}", content_disposition);
    }
    if let Some(content_encoding) = response.content_encoding()? {
        println!("content-encoding: {:?}", content_encoding);
    }
    Ok(())
}
§Available headers
Source

pub async fn get_tags( &self, options: Option<BlobClientGetTagsOptions<'_>>, ) -> Result<Response<BlobTags, XmlFormat>>

Gets the tags of the specified blob.

§Arguments
  • options - Optional parameters for the request.
Source

pub async fn release_lease( &self, lease_id: String, options: Option<BlobClientReleaseLeaseOptions<'_>>, ) -> Result<Response<BlobClientReleaseLeaseResult, NoFormat>>

Frees the lease if it’s no longer needed, so that another client can immediately acquire a lease against the blob.

§Arguments
  • lease_id - A lease ID for the resource. The resource must have an active lease and the lease ID must match.
  • options - Optional parameters for the request.
§Response Headers

The returned Response implements the BlobClientReleaseLeaseResultHeaders trait, which provides access to response headers. For example:

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobClientReleaseLeaseResult, BlobClientReleaseLeaseResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobClientReleaseLeaseResult, NoFormat> = unimplemented!();
    // Access response headers
    if let Some(etag) = response.etag()? {
        println!("etag: {:?}", etag);
    }
    if let Some(last_modified) = response.last_modified()? {
        println!("last-modified: {:?}", last_modified);
    }
    Ok(())
}
§Available headers
Source

pub async fn renew_lease( &self, lease_id: String, options: Option<BlobClientRenewLeaseOptions<'_>>, ) -> Result<Response<BlobClientRenewLeaseResult, NoFormat>>

Renews an existing lease.

§Arguments
  • lease_id - A lease ID for the resource. The resource must have an active lease and the lease ID must match.
  • options - Optional parameters for the request.
§Response Headers

The returned Response implements the BlobClientRenewLeaseResultHeaders trait, which provides access to response headers. For example:

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobClientRenewLeaseResult, BlobClientRenewLeaseResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobClientRenewLeaseResult, NoFormat> = unimplemented!();
    // Access response headers
    if let Some(etag) = response.etag()? {
        println!("etag: {:?}", etag);
    }
    if let Some(last_modified) = response.last_modified()? {
        println!("last-modified: {:?}", last_modified);
    }
    if let Some(lease_id) = response.lease_id()? {
        println!("x-ms-lease-id: {:?}", lease_id);
    }
    Ok(())
}
§Available headers
Source

pub async fn set_immutability_policy( &self, expiry: &OffsetDateTime, options: Option<BlobClientSetImmutabilityPolicyOptions<'_>>, ) -> Result<Response<(), NoFormat>>

Set the immutability policy on the specified blob.

§Arguments
  • expiry - The date-time that indicates the time at which the blob immutability policy will expire.
  • options - Optional parameters for the request.

Sets a legal hold on the specified blob.

§Arguments
  • legal_hold - Indicates whether the blob has a legal hold.
  • options - Optional parameters for the request.
Source

pub async fn set_metadata( &self, metadata: &HashMap<String, String>, options: Option<BlobClientSetMetadataOptions<'_>>, ) -> Result<Response<(), NoFormat>>

Sets user-defined metadata for the specified blob.

§Arguments
  • metadata - The metadata headers.
  • options - Optional parameters for the request.
Source

pub async fn set_properties( &self, options: Option<BlobClientSetPropertiesOptions<'_>>, ) -> Result<Response<(), NoFormat>>

Sets system properties on the specified blob.

§Arguments
  • options - Optional parameters for the request.
Source

pub async fn set_tags( &self, tags: RequestContent<BlobTags, XmlFormat>, options: Option<BlobClientSetTagsOptions<'_>>, ) -> Result<Response<(), NoFormat>>

Sets the tags of the specified blob.

§Arguments
  • tags - The blob tags.
  • options - Optional parameters for the request.
Source

pub async fn set_tier( &self, tier: AccessTier, options: Option<BlobClientSetTierOptions<'_>>, ) -> Result<Response<(), NoFormat>>

Sets the tier of the specified blob.

§Arguments
  • tier - Indicates the tier to be set on the blob.
  • options - Optional parameters for the request.
Source

pub async fn start_copy_from_url( &self, copy_source: String, options: Option<BlobClientStartCopyFromUrlOptions<'_>>, ) -> Result<Response<BlobClientStartCopyFromUrlResult, NoFormat>>

Starts an asynchronous copy from a source URL to a destination blob.

§Arguments
  • copy_source - Specifies the name of the source URL for the copy operation. The value should be URL-encoded as it would appear in a request URI.
  • options - Optional parameters for the request.
§Response Headers

The returned Response implements the BlobClientStartCopyFromUrlResultHeaders trait, which provides access to response headers. For example:

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobClientStartCopyFromUrlResult, BlobClientStartCopyFromUrlResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobClientStartCopyFromUrlResult, NoFormat> = unimplemented!();
    // Access response headers
    if let Some(etag) = response.etag()? {
        println!("etag: {:?}", etag);
    }
    if let Some(last_modified) = response.last_modified()? {
        println!("last-modified: {:?}", last_modified);
    }
    if let Some(copy_id) = response.copy_id()? {
        println!("x-ms-copy-id: {:?}", copy_id);
    }
    Ok(())
}
§Available headers
Source

pub async fn undelete( &self, options: Option<BlobClientUndeleteOptions<'_>>, ) -> Result<Response<(), NoFormat>>

Undelete the specified previously soft deleted blob.

§Arguments
  • options - Optional parameters for the request.

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ServiceExt for T

Source§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
Source§

fn decompression(self) -> Decompression<Self>
where Self: Sized,

Decompress response bodies. Read more
Source§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
Source§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
Source§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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