<PackageReference Include="Azure.Storage.Blobs" Version="12.28.0" />

Azure.Storage.Blobs.BlobContainerClient

public class BlobContainerClient
The BlobContainerClient allows you to manipulate Azure Storage containers and their blobs.
public static readonly string LogsBlobContainerName

The Azure Storage name used to identify a storage account's logs container.

public static readonly string RootBlobContainerName

The Azure Storage name used to identify a storage account's root container.

public static readonly string WebBlobContainerName

The Azure Storage name used to identify a storage account's web content container.

public virtual string AccountName { get; }

Gets the Storage account name corresponding to the container client.

public virtual bool CanGenerateSasUri { get; }

Indicates whether the client is able to generate a SAS uri. Client can generate a SAS url if it is authenticated with a StorageSharedKeyCredential.

public virtual string Name { get; }

Gets the name of the container.

public virtual Uri Uri { get; }

Gets the container's primary Uri endpoint.

protected BlobContainerClient()

Initializes a new instance of the BlobContainerClient class for mocking.

public BlobContainerClient(string connectionString, string blobContainerName)

Initializes a new instance of the BlobContainerClient class with Connection string and Blob Container name.

public BlobContainerClient(string connectionString, string blobContainerName, BlobClientOptions options)

Initializes a new instance of the BlobContainerClient class with Connection string, Blob Container name, and BlobClientOptions.

public BlobContainerClient(Uri blobContainerUri, BlobClientOptions options = null)

Initializes a new instance of the BlobContainerClient class with Blob Container URI and BlobClientOptions.

public BlobContainerClient(Uri blobContainerUri, StorageSharedKeyCredential credential, BlobClientOptions options = null)

Initializes a new instance of the BlobContainerClient class with Blob Container URI, StorageSharedKeyCredential, and BlobClientOptions.

public BlobContainerClient(Uri blobContainerUri, AzureSasCredential credential, BlobClientOptions options = null)

Initializes a new instance of the BlobContainerClient class with Blob Container URI, AzureSasCredential, and BlobClientOptions.

public BlobContainerClient(Uri blobContainerUri, TokenCredential credential, BlobClientOptions options = null)

Initializes a new instance of the BlobContainerClient class with Blob Container URI, TokenCredential, and BlobClientOptions.

protected static BlobContainerClient CreateClient(Uri containerUri, BlobClientOptions options, HttpPipeline pipeline)

Initializes a new instance of the BlobContainerClient class with Blob Container URI, BlobClientOptions, and HttpPipeline.

public virtual Response<BlobContainerInfo> Create(PublicAccessType publicAccessType = 0, IDictionary<string, string> metadata = null, BlobContainerEncryptionScopeOptions encryptionScopeOptions = null, CancellationToken cancellationToken = default)

The Create operation creates a new container under the specified account. If the container with the same name already exists, the operation fails. For more information, see Create Container.

public virtual Response<BlobContainerInfo> Create(PublicAccessType publicAccessType, IDictionary<string, string> metadata, CancellationToken cancellationToken)

The Create operation creates a new container under the specified account. If the container with the same name already exists, the operation fails. For more information, see Create Container.

public virtual Task<Response<BlobContainerInfo>> CreateAsync(PublicAccessType publicAccessType = 0, IDictionary<string, string> metadata = null, BlobContainerEncryptionScopeOptions encryptionScopeOptions = null, CancellationToken cancellationToken = default)

The CreateAsync operation creates a new container under the specified account. If the container with the same name already exists, the operation fails. For more information, see Create Container.

public virtual Task<Response<BlobContainerInfo>> CreateAsync(PublicAccessType publicAccessType, IDictionary<string, string> metadata, CancellationToken cancellationToken)

The CreateAsync operation creates a new container under the specified account. If the container with the same name already exists, the operation fails. For more information, see Create Container.

public virtual Response<BlobContainerInfo> CreateIfNotExists(PublicAccessType publicAccessType = 0, IDictionary<string, string> metadata = null, BlobContainerEncryptionScopeOptions encryptionScopeOptions = null, CancellationToken cancellationToken = default)

The CreateIfNotExists operation creates a new container under the specified account. If the container with the same name already exists, it is not changed. For more information, see Create Container.

public virtual Response<BlobContainerInfo> CreateIfNotExists(PublicAccessType publicAccessType, IDictionary<string, string> metadata, CancellationToken cancellationToken)

The CreateIfNotExists operation creates a new container under the specified account. If the container with the same name already exists, it is not changed. For more information, see Create Container.

public virtual Task<Response<BlobContainerInfo>> CreateIfNotExistsAsync(PublicAccessType publicAccessType = 0, IDictionary<string, string> metadata = null, BlobContainerEncryptionScopeOptions encryptionScopeOptions = null, CancellationToken cancellationToken = default)

The CreateIfNotExistsAsync operation creates a new container under the specified account. If the container with the same name already exists, it is not changed. For more information, see Create Container.

public virtual Task<Response<BlobContainerInfo>> CreateIfNotExistsAsync(PublicAccessType publicAccessType, IDictionary<string, string> metadata, CancellationToken cancellationToken)

The CreateIfNotExists operation creates a new container under the specified account. If the container with the same name already exists, it is not changed. For more information, see Create Container.

public virtual Response Delete(BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The Delete operation marks the specified container for deletion. For more information, see Delete Container.

public virtual Task<Response> DeleteAsync(BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The DeleteAsync operation marks the specified container for deletion. For more information, see Delete Container.

public virtual Response DeleteBlob(string blobName, DeleteSnapshotsOption snapshotsOption = 0, BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The DeleteBlob operation marks the specified blob or snapshot for deletion. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time using IncludeSnapshots. For more information, see Delete Blob.

public virtual Task<Response> DeleteBlobAsync(string blobName, DeleteSnapshotsOption snapshotsOption = 0, BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The DeleteBlobAsync operation marks the specified blob or snapshot for deletion. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time using IncludeSnapshots. For more information, see Delete Blob.

public virtual Response<bool> DeleteBlobIfExists(string blobName, DeleteSnapshotsOption snapshotsOption = 0, BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The DeleteBlobIfExists operation marks the specified blob or snapshot for deletion, if the blob or snapshot exists. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time using IncludeSnapshots. For more information, see Delete Blob.

public virtual Task<Response<bool>> DeleteBlobIfExistsAsync(string blobName, DeleteSnapshotsOption snapshotsOption = 0, BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The DeleteBlobIfExistsAsync operation marks the specified blob or snapshot for deletion, if the blob or snapshot exists. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time using IncludeSnapshots. For more information, see Delete Blob.

public virtual Response<bool> DeleteIfExists(BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The DeleteIfExists operation marks the specified container for deletion if it exists. For more information, see Delete Container.

public virtual Task<Response<bool>> DeleteIfExistsAsync(BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The DeleteIfExistsAsync operation marks the specified container for deletion if it exists. For more information, see Delete Container.

public virtual Response<bool> Exists(CancellationToken cancellationToken = default)

The Exists operation can be called on a BlobContainerClient to see if the associated container exists on the storage account in the storage service.

public virtual Task<Response<bool>> ExistsAsync(CancellationToken cancellationToken = default)

The ExistsAsync operation can be called on a BlobContainerClient to see if the associated container exists on the storage account in the storage service.

public virtual Pageable<TaggedBlobItem> FindBlobsByTags(string tagFilterSqlExpression, CancellationToken cancellationToken = default)

The Filter Blobs operation enables callers to list blobs in the container whose tags match a given search expression and only the tags appearing in the expression will be returned. For more information, see Find Blobs by Tags.

public virtual AsyncPageable<TaggedBlobItem> FindBlobsByTagsAsync(string tagFilterSqlExpression, CancellationToken cancellationToken = default)

The Filter Blobs operation enables callers to list blobs in the container whose tags match a given search expression and only the tags appearing in the expression will be returned. For more information, see Find Blobs by Tags.

public virtual Uri GenerateSasUri(BlobContainerSasPermissions permissions, DateTimeOffset expiresOn)

The GenerateSasUri returns a Uri that generates a Blob Container Service Shared Access Signature (SAS) Uri based on the Client properties and parameters passed. The SAS is signed by the shared key credential of the client. To check if the client is able to sign a Service Sas see CanGenerateSasUri. For more information, see Constructing a service SAS.

public virtual Uri GenerateSasUri(BlobContainerSasPermissions permissions, DateTimeOffset expiresOn, out string stringToSign)

The GenerateSasUri returns a Uri that generates a Blob Container Service Shared Access Signature (SAS) Uri based on the Client properties and parameters passed. The SAS is signed by the shared key credential of the client. To check if the client is able to sign a Service Sas see CanGenerateSasUri. For more information, see Constructing a service SAS.

public virtual Uri GenerateSasUri(BlobSasBuilder builder)

The GenerateSasUri returns a Uri that generates a Blob Container Service Shared Access Signature (SAS) Uri based on the Client properties and builder passed. The SAS is signed by the shared key credential of the client. To check if the client is able to sign a Service Sas see CanGenerateSasUri. For more information, see Constructing a Service SAS.

public virtual Uri GenerateSasUri(BlobSasBuilder builder, out string stringToSign)

The GenerateSasUri returns a Uri that generates a Blob Container Service Shared Access Signature (SAS) Uri based on the Client properties and builder passed. The SAS is signed by the shared key credential of the client. To check if the client is able to sign a Service Sas see CanGenerateSasUri. For more information, see Constructing a Service SAS.

public virtual Uri GenerateUserDelegationSasUri(BlobContainerSasPermissions permissions, DateTimeOffset expiresOn, UserDelegationKey userDelegationKey)

The GenerateUserDelegationSasUri returns a Uri representing a Blob Container Service Shared Access Signature (SAS) Uri based on the Client properties and parameters passed. The SAS is signed by the user delegation key that is passed in. For more information, see Creating an user delegation SAS.

public virtual Uri GenerateUserDelegationSasUri(BlobContainerSasPermissions permissions, DateTimeOffset expiresOn, UserDelegationKey userDelegationKey, out string stringToSign)

The GenerateUserDelegationSasUri returns a Uri representing a Blob Container Service Shared Access Signature (SAS) Uri based on the Client properties and parameters passed. The SAS is signed by the user delegation key that is passed in. For more information, see Creating an user delegation SAS.

public virtual Uri GenerateUserDelegationSasUri(BlobSasBuilder builder, UserDelegationKey userDelegationKey)

The GenerateUserDelegationSasUri returns a Uri representing a Blob Container Service Shared Access Signature (SAS) Uri based on the Client properties and builder passed. The SAS is signed by the user delegation key that is passed in. For more information, see Creating an user delegation SAS.

public virtual Uri GenerateUserDelegationSasUri(BlobSasBuilder builder, UserDelegationKey userDelegationKey, out string stringToSign)

The GenerateUserDelegationSasUri returns a Uri representing a Blob Container Service Shared Access Signature (SAS) Uri based on the Client properties and builder passed. The SAS is signed by the user delegation key that is passed in. For more information, see Creating an user delegation SAS.

public virtual Response<BlobContainerAccessPolicy> GetAccessPolicy(BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The GetAccessPolicy operation gets the permissions for this container. The permissions indicate whether container data may be accessed publicly. For more information, see Get Container ACL.

public virtual Task<Response<BlobContainerAccessPolicy>> GetAccessPolicyAsync(BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The GetAccessPolicyAsync operation gets the permissions for this container. The permissions indicate whether container data may be accessed publicly. For more information, see Get Container ACL.

public virtual Response<AccountInfo> GetAccountInfo(CancellationToken cancellationToken = default)

The GetAccountInfo operation returns the sku name and account kind for the specified account. For more information, see Get Account Information.

public virtual Task<Response<AccountInfo>> GetAccountInfoAsync(CancellationToken cancellationToken = default)

The GetAccountInfoAsync operation returns the sku name and account kind for the specified account. For more information, see Get Account Information.

public virtual BlobClient GetBlobClient(string blobName)

Create a new BlobClient object by appending blobName to the end of Uri. The new BlobClient uses the same request policy pipeline as the BlobContainerClient.

public virtual Pageable<BlobItem> GetBlobs(GetBlobsOptions options = null, CancellationToken cancellationToken = default)

The GetBlobs operation returns an async sequence of blobs in this container. Enumerating the blobs may make multiple requests to the service while fetching all the values. Blobs are ordered lexicographically by name. For more information, see List Blobs.

public virtual Pageable<BlobItem> GetBlobs(BlobTraits traits, BlobStates states, string prefix, CancellationToken cancellationToken)

The GetBlobs operation returns an async sequence of blobs in this container. Enumerating the blobs may make multiple requests to the service while fetching all the values. Blobs are ordered lexicographically by name. For more information, see List Blobs.

public virtual AsyncPageable<BlobItem> GetBlobsAsync(GetBlobsOptions options = null, CancellationToken cancellationToken = default)

The GetBlobsAsync operation returns an async sequence of blobs in this container. Enumerating the blobs may make multiple requests to the service while fetching all the values. Blobs are ordered lexicographically by name. For more information, see List Blobs.

public virtual AsyncPageable<BlobItem> GetBlobsAsync(BlobTraits traits, BlobStates states, string prefix, CancellationToken cancellationToken)

The GetBlobsAsync operation returns an async sequence of blobs in this container. Enumerating the blobs may make multiple requests to the service while fetching all the values. Blobs are ordered lexicographically by name. For more information, see List Blobs.

public virtual Pageable<BlobHierarchyItem> GetBlobsByHierarchy(GetBlobsByHierarchyOptions options = null, CancellationToken cancellationToken = default)

The GetBlobsByHierarchy operation returns an async collection of blobs in this container. Enumerating the blobs may make multiple requests to the service while fetching all the values. Blobs are ordered lexicographically by name. A Delimiter can be used to traverse a virtual hierarchy of blobs as though it were a file system. For more information, see List Blobs.

public virtual Pageable<BlobHierarchyItem> GetBlobsByHierarchy(BlobTraits traits, BlobStates states, string delimiter, string prefix, CancellationToken cancellationToken = default)

The GetBlobsByHierarchyAsync operation returns an async collection of blobs in this container. Enumerating the blobs may make multiple requests to the service while fetching all the values. Blobs are ordered lexicographically by name. A delimiter can be used to traverse a virtual hierarchy of blobs as though it were a file system. For more information, see List Blobs.

public virtual AsyncPageable<BlobHierarchyItem> GetBlobsByHierarchyAsync(GetBlobsByHierarchyOptions options = null, CancellationToken cancellationToken = default)

The GetBlobsByHierarchy operation returns an async collection of blobs in this container. Enumerating the blobs may make multiple requests to the service while fetching all the values. Blobs are ordered lexicographically by name. A Delimiter can be used to traverse a virtual hierarchy of blobs as though it were a file system. For more information, see List Blobs.

public virtual AsyncPageable<BlobHierarchyItem> GetBlobsByHierarchyAsync(BlobTraits traits, BlobStates states, string delimiter, string prefix, CancellationToken cancellationToken)

The GetBlobsByHierarchyAsync operation returns an async collection of blobs in this container. Enumerating the blobs may make multiple requests to the service while fetching all the values. Blobs are ordered lexicographically by name. A delimiter can be used to traverse a virtual hierarchy of blobs as though it were a file system. For more information, see List Blobs.

public virtual Response<BlobContainerProperties> GetProperties(BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The GetProperties operation returns all user-defined metadata and system properties for the specified container. The data returned does not include the container's list of blobs. For more information, see Get Container Properties.

public virtual Task<Response<BlobContainerProperties>> GetPropertiesAsync(BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The GetPropertiesAsync operation returns all user-defined metadata and system properties for the specified container. The data returned does not include the container's list of blobs. For more information, see Get Container Properties.

public virtual Response<BlobContainerInfo> SetAccessPolicy(PublicAccessType accessType = 0, IEnumerable<BlobSignedIdentifier> permissions = null, BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The SetAccessPolicy operation sets the permissions for the specified container. The permissions indicate whether blob container data may be accessed publicly. For more information, see Set Container ACL.

public virtual Task<Response<BlobContainerInfo>> SetAccessPolicyAsync(PublicAccessType accessType = 0, IEnumerable<BlobSignedIdentifier> permissions = null, BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The SetAccessPolicyAsync operation sets the permissions for the specified container. The permissions indicate whether blob container data may be accessed publicly. For more information, see Set Container ACL.

public virtual Response<BlobContainerInfo> SetMetadata(IDictionary<string, string> metadata, BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The SetMetadata operation sets one or more user-defined name-value pairs for the specified container. For more information, see Set Container Metadata.

public virtual Task<Response<BlobContainerInfo>> SetMetadataAsync(IDictionary<string, string> metadata, BlobRequestConditions conditions = null, CancellationToken cancellationToken = default)

The SetMetadataAsync operation sets one or more user-defined name-value pairs for the specified container. For more information, see Set Container Metadata.

public virtual Response<BlobContentInfo> UploadBlob(string blobName, Stream content, CancellationToken cancellationToken = default)

The UploadBlob operation creates a new block blob. For partial block blob updates and other advanced features, please see BlockBlobClient. To create or modify page or append blobs, please see PageBlobClient or AppendBlobClient. For more information, see Put Blob.

public virtual Response<BlobContentInfo> UploadBlob(string blobName, BinaryData content, CancellationToken cancellationToken = default)

The UploadBlob operation creates a new block blob. For partial block blob updates and other advanced features, please see BlockBlobClient. To create or modify page or append blobs, please see PageBlobClient or AppendBlobClient. For more information, see Put Blob.

public virtual Task<Response<BlobContentInfo>> UploadBlobAsync(string blobName, Stream content, CancellationToken cancellationToken = default)

The UploadBlobAsync operation creates a new block blob. For partial block blob updates and other advanced features, please see BlockBlobClient. To create or modify page or append blobs, please see PageBlobClient or AppendBlobClient. For more information, see Put Blob.

public virtual Task<Response<BlobContentInfo>> UploadBlobAsync(string blobName, BinaryData content, CancellationToken cancellationToken = default)

The UploadBlobAsync operation creates a new block blob. For partial block blob updates and other advanced features, please see BlockBlobClient. To create or modify page or append blobs, please see PageBlobClient or AppendBlobClient. For more information, see Put Blob.