Skip to main content

BlobContainerClient

Struct BlobContainerClient 

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

Implementations§

Source§

impl BlobContainerClient

Source

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

Creates a new BlobContainerClient from a container URL.

§Arguments
  • container_url - The full URL of the container, for example https://myaccount.blob.core.windows.net/mycontainer. 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 blob_client(&self, blob_name: &str) -> BlobClient

Returns a new instance of BlobClient.

§Arguments
  • blob_name - The name of the blob.
Source

pub fn url(&self) -> &Url

Gets the URL of the container.

Source

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

Checks if the container exists.

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

Source§

impl BlobContainerClient

Source

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

Requests a new lease on the specified container.

§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 BlobContainerClientAcquireLeaseResultHeaders trait, which provides access to response headers. For example:

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobContainerClientAcquireLeaseResult, BlobContainerClientAcquireLeaseResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobContainerClientAcquireLeaseResult, 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<BlobContainerClientBreakLeaseOptions<'_>>, ) -> Result<Response<BlobContainerClientBreakLeaseResult, 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 BlobContainerClientBreakLeaseResultHeaders trait, which provides access to response headers. For example:

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobContainerClientBreakLeaseResult, BlobContainerClientBreakLeaseResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobContainerClientBreakLeaseResult, 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<BlobContainerClientChangeLeaseOptions<'_>>, ) -> Result<Response<BlobContainerClientChangeLeaseResult, 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 BlobContainerClientChangeLeaseResultHeaders trait, which provides access to response headers. For example:

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobContainerClientChangeLeaseResult, BlobContainerClientChangeLeaseResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobContainerClientChangeLeaseResult, 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( &self, options: Option<BlobContainerClientCreateOptions<'_>>, ) -> Result<Response<(), NoFormat>>

Creates a new container in the specified account. If the container with the same name already exists, the operation fails.

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

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

Deletes the specified container.

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

pub fn find_blobs_by_tags( &self, filter_expression: &str, options: Option<BlobContainerClientFindBlobsByTagsOptions<'_>>, ) -> Result<Pager<FilteredBlobResponse, XmlFormat>>

Lists blobs in the specified container whose tags match a given search expression.

§Arguments
  • filter_expression - Filters the results to return only blobs whose tags match the specified expression.
  • options - Optional parameters for the request.
Source

pub async fn get_access_policy( &self, options: Option<BlobContainerClientGetAccessPolicyOptions<'_>>, ) -> Result<Response<SignedIdentifiers, XmlFormat>>

Gets the permissions for the specified container.

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

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

use azure_core::{Result, http::{Response, XmlFormat}};
use azure_storage_blob::models::{SignedIdentifiers, SignedIdentifiersHeaders};
async fn example() -> Result<()> {
    let response: Response<SignedIdentifiers, XmlFormat> = 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(access) = response.access()? {
        println!("x-ms-blob-public-access: {:?}", access);
    }
    Ok(())
}
§Available headers
Source

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

Returns information about the storage account.

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

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

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobContainerClientGetAccountInfoResult, BlobContainerClientGetAccountInfoResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobContainerClientGetAccountInfoResult, 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<BlobContainerClientGetPropertiesOptions<'_>>, ) -> Result<Response<BlobContainerClientGetPropertiesResult, NoFormat>>

Returns all user-defined metadata and system properties for the specified container. The data returned does not include the container’s list of blobs.

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

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

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobContainerClientGetPropertiesResult, BlobContainerClientGetPropertiesResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobContainerClientGetPropertiesResult, 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(access) = response.access()? {
        println!("x-ms-blob-public-access: {:?}", access);
    }
    Ok(())
}
§Available headers
Source

pub fn list_blobs( &self, options: Option<BlobContainerClientListBlobsOptions<'_>>, ) -> Result<Pager<ListBlobsResponse, XmlFormat>>

Returns a list of the blobs in the specified container.

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

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

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

§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 BlobContainerClientReleaseLeaseResultHeaders trait, which provides access to response headers. For example:

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobContainerClientReleaseLeaseResult, BlobContainerClientReleaseLeaseResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobContainerClientReleaseLeaseResult, 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<BlobContainerClientRenewLeaseOptions<'_>>, ) -> Result<Response<BlobContainerClientRenewLeaseResult, 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 BlobContainerClientRenewLeaseResultHeaders trait, which provides access to response headers. For example:

use azure_core::{Result, http::{Response, NoFormat}};
use azure_storage_blob::models::{BlobContainerClientRenewLeaseResult, BlobContainerClientRenewLeaseResultHeaders};
async fn example() -> Result<()> {
    let response: Response<BlobContainerClientRenewLeaseResult, 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_access_policy( &self, container_acl: RequestContent<SignedIdentifiers, XmlFormat>, options: Option<BlobContainerClientSetAccessPolicyOptions<'_>>, ) -> Result<Response<(), NoFormat>>

Sets the permissions for the specified container.

§Arguments
  • container_acl - The access control list for the container.
  • options - Optional parameters for the request.
Source

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

Sets user-defined metadata for the specified container.

§Arguments
  • metadata - The metadata headers.
  • 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