pub struct BlobClient { /* private fields */ }Implementations§
Source§impl BlobClient
impl BlobClient
Sourcepub fn new(
blob_url: Url,
credential: Option<Arc<dyn TokenCredential>>,
options: Option<BlobClientOptions>,
) -> Result<Self>
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 examplehttps://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 ofTokenCredentialthat can provide an Entra ID token to use when authenticating.options- Optional configuration for the client.
Sourcepub fn append_blob_client(&self) -> AppendBlobClient
pub fn append_blob_client(&self) -> AppendBlobClient
Returns a new instance of AppendBlobClient.
Sourcepub fn block_blob_client(&self) -> BlockBlobClient
pub fn block_blob_client(&self) -> BlockBlobClient
Returns a new instance of BlockBlobClient.
Sourcepub fn page_blob_client(&self) -> PageBlobClient
pub fn page_blob_client(&self) -> PageBlobClient
Returns a new instance of PageBlobClient.
Sourcepub fn with_version(&self, version_id: &str) -> Result<Self>
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.
Sourcepub fn with_snapshot(&self, snapshot: &str) -> Result<Self>
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.
Sourcepub async fn download(
&self,
options: Option<BlobClientDownloadOptions<'_>>,
) -> Result<BlobClientDownloadResult>
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.
Sourcepub async fn download_into(
&self,
buffer: &mut [u8],
options: Option<BlobClientDownloadOptions<'_>>,
) -> Result<BlobClientDownloadIntoResult>
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.
Sourcepub async fn upload(
&self,
content: RequestContent<Bytes, NoFormat>,
options: Option<BlobClientUploadOptions<'_>>,
) -> Result<BlobClientUploadResult>
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§impl BlobClient
impl BlobClient
Sourcepub async fn abort_copy(
&self,
copy_id: &str,
options: Option<BlobClientAbortCopyOptions<'_>>,
) -> Result<Response<(), NoFormat>>
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.
Sourcepub async fn acquire_lease(
&self,
duration: i32,
options: Option<BlobClientAcquireLeaseOptions<'_>>,
) -> Result<Response<BlobClientAcquireLeaseResult, NoFormat>>
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
etag() - etaglast_modified() - last-modifiedlease_id() - x-ms-lease-id
Sourcepub async fn break_lease(
&self,
options: Option<BlobClientBreakLeaseOptions<'_>>,
) -> Result<Response<BlobClientBreakLeaseResult, NoFormat>>
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
etag() - etaglast_modified() - last-modifiedlease_time() - x-ms-lease-time
Sourcepub async fn change_lease(
&self,
lease_id: String,
proposed_lease_id: String,
options: Option<BlobClientChangeLeaseOptions<'_>>,
) -> Result<Response<BlobClientChangeLeaseResult, NoFormat>>
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
etag() - etaglast_modified() - last-modifiedlease_id() - x-ms-lease-id
Sourcepub async fn create_snapshot(
&self,
options: Option<BlobClientCreateSnapshotOptions<'_>>,
) -> Result<Response<BlobClientCreateSnapshotResult, NoFormat>>
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
etag() - etaglast_modified() - last-modifiedis_server_encrypted() - x-ms-request-server-encryptedsnapshot() - x-ms-snapshotversion_id() - x-ms-version-id
Sourcepub async fn delete(
&self,
options: Option<BlobClientDeleteOptions<'_>>,
) -> Result<Response<(), NoFormat>>
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.
Sourcepub async fn delete_immutability_policy(
&self,
options: Option<BlobClientDeleteImmutabilityPolicyOptions<'_>>,
) -> Result<Response<(), NoFormat>>
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.
Sourcepub async fn get_account_info(
&self,
options: Option<BlobClientGetAccountInfoOptions<'_>>,
) -> Result<Response<BlobClientGetAccountInfoResult, NoFormat>>
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
account_kind() - x-ms-account-kindis_hierarchical_namespace_enabled() - x-ms-is-hns-enabledsku_name() - x-ms-sku-name
Sourcepub async fn get_properties(
&self,
options: Option<BlobClientGetPropertiesOptions<'_>>,
) -> Result<Response<BlobClientGetPropertiesResult, NoFormat>>
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
cache_control() - cache-controlcontent_disposition() - content-dispositioncontent_encoding() - content-encodingcontent_language() - content-languagecontent_length() - content-lengthcontent_md5() - content-md5content_type() - content-typeetag() - etaglast_modified() - last-modifiedaccess_tier() - x-ms-access-tieraccess_tier_change_time() - x-ms-access-tier-change-timeaccess_tier_inferred() - x-ms-access-tier-inferredarchive_status() - x-ms-archive-statusblob_committed_block_count() - x-ms-blob-committed-block-countis_sealed() - x-ms-blob-sealedblob_sequence_number() - x-ms-blob-sequence-numberblob_type() - x-ms-blob-typecopy_completion_time() - x-ms-copy-completion-timedestination_snapshot() - x-ms-copy-destination-snapshotcopy_id() - x-ms-copy-idcopy_progress() - x-ms-copy-progresscopy_source() - x-ms-copy-sourcecopy_status() - x-ms-copy-statuscopy_status_description() - x-ms-copy-status-descriptioncreation_time() - x-ms-creation-timeencryption_key_sha256() - x-ms-encryption-key-sha256encryption_scope() - x-ms-encryption-scopeexpires_on() - x-ms-expiry-timeimmutability_policy_mode() - x-ms-immutability-policy-modeimmutability_policy_expires_on() - x-ms-immutability-policy-until-dateis_incremental_copy() - x-ms-incremental-copyis_current_version() - x-ms-is-current-versionlast_accessed() - x-ms-last-access-timeduration() - x-ms-lease-durationlease_state() - x-ms-lease-statelease_status() - x-ms-lease-statuslegal_hold() - x-ms-legal-holdmetadata() - x-ms-metaobject_replication_rules() - x-ms-orobject_replication_policy_id() - x-ms-or-policy-idrehydrate_priority() - x-ms-rehydrate-priorityis_server_encrypted() - x-ms-server-encryptedtag_count() - x-ms-tag-countversion_id() - x-ms-version-id
Sourcepub async fn release_lease(
&self,
lease_id: String,
options: Option<BlobClientReleaseLeaseOptions<'_>>,
) -> Result<Response<BlobClientReleaseLeaseResult, NoFormat>>
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
etag() - etaglast_modified() - last-modified
Sourcepub async fn renew_lease(
&self,
lease_id: String,
options: Option<BlobClientRenewLeaseOptions<'_>>,
) -> Result<Response<BlobClientRenewLeaseResult, NoFormat>>
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
etag() - etaglast_modified() - last-modifiedlease_id() - x-ms-lease-id
Sourcepub async fn set_immutability_policy(
&self,
expiry: &OffsetDateTime,
options: Option<BlobClientSetImmutabilityPolicyOptions<'_>>,
) -> Result<Response<(), NoFormat>>
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.
Sourcepub async fn set_legal_hold(
&self,
legal_hold: bool,
options: Option<BlobClientSetLegalHoldOptions<'_>>,
) -> Result<Response<(), NoFormat>>
pub async fn set_legal_hold( &self, legal_hold: bool, options: Option<BlobClientSetLegalHoldOptions<'_>>, ) -> Result<Response<(), NoFormat>>
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.
Sourcepub async fn set_metadata(
&self,
metadata: &HashMap<String, String>,
options: Option<BlobClientSetMetadataOptions<'_>>,
) -> Result<Response<(), NoFormat>>
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.
Sourcepub async fn set_properties(
&self,
options: Option<BlobClientSetPropertiesOptions<'_>>,
) -> Result<Response<(), NoFormat>>
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.
Sets the tags of the specified blob.
§Arguments
tags- The blob tags.options- Optional parameters for the request.
Sourcepub async fn set_tier(
&self,
tier: AccessTier,
options: Option<BlobClientSetTierOptions<'_>>,
) -> Result<Response<(), NoFormat>>
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.
Sourcepub async fn start_copy_from_url(
&self,
copy_source: String,
options: Option<BlobClientStartCopyFromUrlOptions<'_>>,
) -> Result<Response<BlobClientStartCopyFromUrlResult, NoFormat>>
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
etag() - etaglast_modified() - last-modifiedcopy_id() - x-ms-copy-idcopy_status() - x-ms-copy-statusversion_id() - x-ms-version-id