BlobClient class

Definition

A client to interact with a specific blob, although that blob may not yet exist.

BlobClient(account_url, container_name, blob_name, snapshot=None, credential=None, **kwargs)
Inheritance
builtins.object
azure.storage.blob._shared.base_client.StorageAccountHostsMixin
BlobClient

Parameters

account_url
str

The URI to the storage account. In order to create a client given the full URI to the blob, use the from_blob_url(blob_url, credential=None, snapshot=None, **kwargs) classmethod.

container_name
str

The container name for the blob.

blob_name
str

The name of the blob with which to interact. If specified, this value will override a blob value specified in the blob URL.

snapshot
str

The optional blob snapshot on which to operate. This can be the snapshot ID string or the response returned from create_snapshot(metadata=None, **kwargs).

credential

The credentials with which to authenticate. This is optional if the account URL already has a SAS token. The value can be a SAS token string, an account shared access key, or an instance of a TokenCredentials class from azure.identity. If the URL already has a SAS token, specifying an explicit credential will take priority.

api_version
str

The Storage API version to use for requests. Default value is '2019-07-07'. Setting to an older version may result in reduced feature compatibility.

New in version 12.2.0.

secondary_hostname
str

The hostname of the secondary endpoint.

max_block_size
int

The maximum chunk size for uploading a block blob in chunks. Defaults to 410241024, or 4MB.

max_single_put_size
int

If the blob size is less than or equal max_single_put_size, then the blob will be uploaded with only one http PUT request. If the blob size is larger than max_single_put_size, the blob will be uploaded in chunks. Defaults to 6410241024, or 64MB.

min_large_block_upload_threshold
int

The minimum chunk size required to use the memory efficient algorithm when uploading a block blob. Defaults to 410241024+1.

use_byte_buffer
bool

Use a byte buffer for block blob uploads. Defaults to False.

max_page_size
int

The maximum chunk size for uploading a page blob. Defaults to 410241024, or 4MB.

max_single_get_size
int

The maximum size for a blob to be downloaded in a single call, the exceeded part will be downloaded in chunks (could be parallel). Defaults to 3210241024, or 32MB.

max_chunk_get_size
int

The maximum chunk size used for downloading a blob. Defaults to 410241024, or 4MB.

Examples

Creating the BlobClient from a URL to a public blob (no auth needed).


   from azure.storage.blob import BlobClient
   blob_client = BlobClient.from_blob_url(blob_url="https://account.blob.core.windows.net/container/blob-name")

Creating the BlobClient from a SAS URL to a blob.


   from azure.storage.blob import BlobClient

   sas_url = "https://account.blob.core.windows.net/container/blob-name?sv=2015-04-05&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=Z%2FRHIX5Xcg0Mq2rqI3OlWTjEg2tYkboXr1P9ZUXDtkk%3D"
   blob_client = BlobClient.from_blob_url(sas_url)

Methods

abort_copy

Abort an ongoing copy operation.

This will leave a destination blob with zero length and full metadata. This will raise an error if the copy operation has already ended.

acquire_lease

Requests a new lease.

If the blob does not have an active lease, the Blob Service creates a lease on the blob and returns a new lease.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

append_block

Commits a new block of data to the end of the existing append blob.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

append_block_from_url

Creates a new block to be committed as part of a blob, where the contents are read from a source url.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

clear_page

Clears a range of pages.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

commit_block_list

The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on destination blob with a matching value.

New in version 12.4.0.

create_append_blob

Creates a new Append Blob.

create_page_blob

Creates a new Page Blob of the specified size.

create_snapshot

Creates a snapshot of the blob.

A snapshot is a read-only version of a blob that's taken at a point in time. It can be read, copied, or deleted, but not modified. Snapshots provide a way to back up a blob as it appears at a moment in time.

A snapshot of a blob has the same name as the base blob from which the snapshot is taken, with a DateTime value appended to indicate the time at which the snapshot was taken.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on destination blob with a matching value.

New in version 12.4.0.

delete_blob

Marks the specified blob for deletion.

The blob is later deleted during garbage collection. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time with the delete_blob() operation.

If a delete retention policy is enabled for the service, then this operation soft deletes the blob and retains the blob for a specified number of days. After the specified number of days, the blob's data is removed from the service during garbage collection. Soft deleted blob is accessible through list_blobs(name_starts_with=None, include=None, **kwargs) specifying include=['deleted'] option. Soft-deleted blob can be restored using <xref:azure.storage.blob.undelete> operation.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

download_blob

Downloads a blob to the StorageStreamDownloader. The readall() method must be used to read all the content or readinto() must be used to download the blob into a stream.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

from_blob_url

Create BlobClient from a blob url. This doesn't support customized blob url with '/' in blob name.

from_connection_string

Create BlobClient from a Connection String.

get_account_information

Gets information related to the storage account in which the blob resides.

The information can also be retrieved if the user has a SAS to a container or blob. The keys in the returned dictionary include 'sku_name' and 'account_kind'.

get_blob_properties

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

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

get_blob_tags

The Get Tags operation enables users to get tags on a blob or specific blob version, or snapshot.

New in version 12.4.0: This operation was introduced in API version '2019-12-12'.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on destination blob with a matching value.

get_block_list

The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on destination blob with a matching value.

New in version 12.4.0.

get_page_range_diff_for_managed_disk

Returns the list of valid page ranges for a managed disk or snapshot.

Note

This operation is only available for managed disk accounts.

New in version 12.2.0: This operation was introduced in API version '2019-07-07'.

get_page_ranges

Returns the list of valid page ranges for a Page Blob or snapshot of a page blob.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

query_blob

Enables users to select/project on blob/or blob snapshot data by providing simple query expressions. This operations returns a BlobQueryReader, users need to use readall() or readinto() to get query data.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

resize_blob

Resizes a page blob to the specified size.

If the specified value is less than the current size of the blob, then all pages above the specified value are cleared.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

seal_append_blob

The Seal operation seals the Append Blob to make it read-only.

New in version 12.4.0.

set_blob_metadata

Sets user-defined metadata for the blob as one or more name-value pairs.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

set_blob_tags

The Set Tags operation enables users to set tags on a blob or specific blob version, but not snapshot. Each call to this operation replaces all existing tags attached to the blob. To remove all tags from the blob, call this operation with no tags set.

New in version 12.4.0: This operation was introduced in API version '2019-12-12'.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on destination blob with a matching value.

set_http_headers

Sets system properties on the blob.

If one property is set for the content_settings, all properties will be overridden.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

set_premium_page_blob_tier

Sets the page blob tiers on the blob. This API is only supported for page blobs on premium accounts.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

set_sequence_number

Sets the blob sequence number.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

set_standard_blob_tier

This operation sets the tier on a block blob.

A block blob's tier determines Hot/Cool/Archive storage type. This operation does not update the blob's ETag.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

stage_block

Creates a new block to be committed as part of a blob.

stage_block_from_url

Creates a new block to be committed as part of a blob where the contents are read from a URL.

start_copy_from_url

Copies a blob asynchronously.

This operation returns a copy operation object that can be used to wait on the completion of the operation, as well as check status or abort the copy operation. The Blob service copies blobs on a best-effort basis.

The source blob for a copy operation may be a block blob, an append blob, or a page blob. If the destination blob already exists, it must be of the same blob type as the source blob. Any existing destination blob will be overwritten. The destination blob cannot be modified while a copy operation is in progress.

When copying from a page blob, the Blob service creates a destination page blob of the source blob's length, initially containing all zeroes. Then the source page ranges are enumerated, and non-empty ranges are copied.

For a block blob or an append blob, the Blob service creates a committed blob of zero length before returning from this operation. When copying from a block blob, all committed blocks and their block IDs are copied. Uncommitted blocks are not copied. At the end of the copy operation, the destination blob will have the same committed block count as the source.

When copying from an append blob, all committed blocks are copied. At the end of the copy operation, the destination blob will have the same committed block count as the source.

For all blob types, you can call status() on the returned polling object to check the status of the copy operation, or wait() to block until the operation is complete. The final blob will be committed when the copy completes.

undelete_blob

Restores soft-deleted blobs or snapshots.

Operation will only be successful if used within the specified number of days set in the delete retention policy.

upload_blob

Creates a new blob from a data source with automatic chunking.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

upload_page

The Upload Pages operation writes a range of pages to a page blob.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

upload_pages_from_url

The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

abort_copy

Abort an ongoing copy operation.

This will leave a destination blob with zero length and full metadata. This will raise an error if the copy operation has already ended.

abort_copy(copy_id, **kwargs)

Parameters

copy_id
str or BlobProperties
Required

The copy operation to abort. This can be either an ID string, or an instance of BlobProperties.

Return type

Examples

Abort copying a blob from URL.


   # Passing in copy id to abort copy operation
   copied_blob.abort_copy(copy_id)

   # check copy status
   props = copied_blob.get_blob_properties()
   print(props.copy.status)

acquire_lease

Requests a new lease.

If the blob does not have an active lease, the Blob Service creates a lease on the blob and returns a new lease.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

acquire_lease(lease_duration=-1, lease_id=None, **kwargs)

Parameters

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

A BlobLeaseClient object.

Return type

Examples

Acquiring a lease on a blob.


   # Acquire a lease on the blob
   lease = blob_client.acquire_lease()

   # Delete blob by passing in the lease
   blob_client.delete_blob(lease=lease)

append_block

Commits a new block of data to the end of the existing append blob.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

append_block(data, length=None, **kwargs)

Parameters

encoding
str
Required

Defaults to UTF-8.

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

encryption_scope
str
Required

A predefined encryption scope used to encrypt the data on the service. An encryption scope can be created using the Management API and referenced here by name. If a default encryption scope has been defined at the container, this value will override it if the container-level scope is configured to allow overrides. Otherwise an error will be raised.

New in version 12.2.0.

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Blob-updated property dict (Etag, last modified, append offset, committed block count).

Return type

dict(str, Any)

append_block_from_url

Creates a new block to be committed as part of a blob, where the contents are read from a source url.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

append_block_from_url(copy_source_url, source_offset=None, source_length=None, **kwargs)

Parameters

source_if_modified_since
datetime
Required

A DateTime value. Azure expects the date value passed in to be UTC. If timezone is included, any non-UTC datetimes will be converted to UTC. If a date is passed in without timezone info, it is assumed to be UTC. Specify this header to perform the operation only if the source resource has been modified since the specified time.

source_if_unmodified_since
datetime
Required

A DateTime value. Azure expects the date value passed in to be UTC. If timezone is included, any non-UTC datetimes will be converted to UTC. If a date is passed in without timezone info, it is assumed to be UTC. Specify this header to perform the operation only if the source resource has not been modified since the specified date/time.

source_etag
str
Required

The source ETag value, or the wildcard character (*). Used to check if the resource has changed, and act according to the condition specified by the match_condition parameter.

source_match_condition
MatchConditions
Required

The source match condition to use upon the etag.

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

encryption_scope
str
Required

A predefined encryption scope used to encrypt the data on the service. An encryption scope can be created using the Management API and referenced here by name. If a default encryption scope has been defined at the container, this value will override it if the container-level scope is configured to allow overrides. Otherwise an error will be raised.

New in version 12.2.0.

timeout
int
Required

The timeout parameter is expressed in seconds.

clear_page

Clears a range of pages.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

clear_page(offset, length, **kwargs)

Parameters

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Blob-updated property dict (Etag and last modified).

Return type

dict(str, Any)

commit_block_list

The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on destination blob with a matching value.

New in version 12.4.0.

commit_block_list(block_list, content_settings=None, metadata=None, **kwargs)

Parameters

standard_blob_tier
StandardBlobTier
Required

A standard blob tier value to set the blob to. For this version of the library, this is only applicable to block blobs on standard storage accounts.

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

encryption_scope
str
Required

A predefined encryption scope used to encrypt the data on the service. An encryption scope can be created using the Management API and referenced here by name. If a default encryption scope has been defined at the container, this value will override it if the container-level scope is configured to allow overrides. Otherwise an error will be raised.

New in version 12.2.0.

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Blob-updated property dict (Etag and last modified).

Return type

dict(str, Any)

create_append_blob

Creates a new Append Blob.

create_append_blob(content_settings=None, metadata=None, **kwargs)

Parameters

content_settings
ContentSettings
Required

ContentSettings object used to set blob properties. Used to set content type, encoding, language, disposition, md5, and cache control.

metadata
dict(str, str)
Required

Name-value pairs associated with the blob as metadata.

tags
dict(str, str)
Required

Name-value pairs associated with the blob as tag. Tags are case-sensitive. The tag set may contain at most 10 tags. Tag keys must be between 1 and 128 characters, and tag values must be between 0 and 256 characters. Valid tag key and value characters include: lowercase and uppercase letters, digits (0-9), space ( >><<), plus (+), minus (-), period (.), solidus (/), colon (:), equals (=), underscore (_)

New in version 12.4.0.

lease
BlobLeaseClient or str
Required

Required if the blob has an active lease. Value can be a BlobLeaseClient object or the lease ID as a string.

if_modified_since
datetime
Required

A DateTime value. Azure expects the date value passed in to be UTC. If timezone is included, any non-UTC datetimes will be converted to UTC. If a date is passed in without timezone info, it is assumed to be UTC. Specify this header to perform the operation only if the resource has been modified since the specified time.

if_unmodified_since
datetime
Required

A DateTime value. Azure expects the date value passed in to be UTC. If timezone is included, any non-UTC datetimes will be converted to UTC. If a date is passed in without timezone info, it is assumed to be UTC. Specify this header to perform the operation only if the resource has not been modified since the specified date/time.

etag
str
Required

An ETag value, or the wildcard character (*). Used to check if the resource has changed, and act according to the condition specified by the match_condition parameter.

match_condition
MatchConditions
Required

The match condition to use upon the etag.

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

encryption_scope
str
Required

A predefined encryption scope used to encrypt the data on the service. An encryption scope can be created using the Management API and referenced here by name. If a default encryption scope has been defined at the container, this value will override it if the container-level scope is configured to allow overrides. Otherwise an error will be raised.

New in version 12.2.0.

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Blob-updated property dict (Etag and last modified).

Return type

dict[str, Any]

create_page_blob

Creates a new Page Blob of the specified size.

create_page_blob(size, content_settings=None, metadata=None, premium_page_blob_tier=None, **kwargs)

Parameters

size
int
Required

This specifies the maximum size for the page blob, up to 1 TB. The page blob size must be aligned to a 512-byte boundary.

content_settings
ContentSettings
Required

ContentSettings object used to set blob properties. Used to set content type, encoding, language, disposition, md5, and cache control.

metadata
dict(str, str)
Required

Name-value pairs associated with the blob as metadata.

premium_page_blob_tier
PremiumPageBlobTier
Required

A page blob tier value to set the blob to. The tier correlates to the size of the blob and number of allowed IOPS. This is only applicable to page blobs on premium storage accounts.

tags
dict(str, str)
Required

Name-value pairs associated with the blob as tag. Tags are case-sensitive. The tag set may contain at most 10 tags. Tag keys must be between 1 and 128 characters, and tag values must be between 0 and 256 characters. Valid tag key and value characters include: lowercase and uppercase letters, digits (0-9), space ( >><<), plus (+), minus (-), period (.), solidus (/), colon (:), equals (=), underscore (_)

New in version 12.4.0.

sequence_number
int
Required

Only for Page blobs. The sequence number is a user-controlled value that you can use to track requests. The value of the sequence number must be between 0 and 2^63 - 1.The default value is 0.

lease
BlobLeaseClient or str
Required

Required if the blob has an active lease. Value can be a BlobLeaseClient object or the lease ID as a string.

if_modified_since
datetime
Required

A DateTime value. Azure expects the date value passed in to be UTC. If timezone is included, any non-UTC datetimes will be converted to UTC. If a date is passed in without timezone info, it is assumed to be UTC. Specify this header to perform the operation only if the resource has been modified since the specified time.

if_unmodified_since
datetime
Required

A DateTime value. Azure expects the date value passed in to be UTC. If timezone is included, any non-UTC datetimes will be converted to UTC. If a date is passed in without timezone info, it is assumed to be UTC. Specify this header to perform the operation only if the resource has not been modified since the specified date/time.

etag
str
Required

An ETag value, or the wildcard character (*). Used to check if the resource has changed, and act according to the condition specified by the match_condition parameter.

match_condition
MatchConditions
Required

The match condition to use upon the etag.

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

encryption_scope
str
Required

A predefined encryption scope used to encrypt the data on the service. An encryption scope can be created using the Management API and referenced here by name. If a default encryption scope has been defined at the container, this value will override it if the container-level scope is configured to allow overrides. Otherwise an error will be raised.

New in version 12.2.0.

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Blob-updated property dict (Etag and last modified).

Return type

dict[str, Any]

create_snapshot

Creates a snapshot of the blob.

A snapshot is a read-only version of a blob that's taken at a point in time. It can be read, copied, or deleted, but not modified. Snapshots provide a way to back up a blob as it appears at a moment in time.

A snapshot of a blob has the same name as the base blob from which the snapshot is taken, with a DateTime value appended to indicate the time at which the snapshot was taken.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on destination blob with a matching value.

New in version 12.4.0.

create_snapshot(metadata=None, **kwargs)

Parameters

lease
BlobLeaseClient or str
Required

Required if the blob has an active lease. Value can be a BlobLeaseClient object or the lease ID as a string.

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

encryption_scope
str
Required

A predefined encryption scope used to encrypt the data on the service. An encryption scope can be created using the Management API and referenced here by name. If a default encryption scope has been defined at the container, this value will override it if the container-level scope is configured to allow overrides. Otherwise an error will be raised.

New in version 12.2.0.

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Blob-updated property dict (Snapshot ID, Etag, and last modified).

Return type

dict[str, Any]

Examples

Create a snapshot of the blob.


   # Create a read-only snapshot of the blob at this point in time
   snapshot_blob = blob_client.create_snapshot()

   # Get the snapshot ID
   print(snapshot_blob.get('snapshot'))

delete_blob

Marks the specified blob for deletion.

The blob is later deleted during garbage collection. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time with the delete_blob() operation.

If a delete retention policy is enabled for the service, then this operation soft deletes the blob and retains the blob for a specified number of days. After the specified number of days, the blob's data is removed from the service during garbage collection. Soft deleted blob is accessible through list_blobs(name_starts_with=None, include=None, **kwargs) specifying include=['deleted'] option. Soft-deleted blob can be restored using <xref:azure.storage.blob.undelete> operation.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

delete_blob(delete_snapshots=False, **kwargs)

Parameters

timeout
int
Required

The timeout parameter is expressed in seconds.

Return type

Examples

Delete a blob.


   blob_client.delete_blob()

download_blob

Downloads a blob to the StorageStreamDownloader. The readall() method must be used to read all the content or readinto() must be used to download the blob into a stream.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

download_blob(offset=None, length=None, **kwargs)

Parameters

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

max_concurrency
int
Required

The number of parallel connections with which to download.

encoding
str
Required

Encoding to decode the downloaded bytes. Default is None, i.e. no decoding.

timeout
int
Required

The timeout parameter is expressed in seconds. This method may make multiple calls to the Azure service and the timeout will apply to each call individually.

Returns

A streaming object (StorageStreamDownloader)

Return type

Examples

Download a blob.


   with open(DEST_FILE, "wb") as my_blob:
       download_stream = blob_client.download_blob()
       my_blob.write(download_stream.readall())

from_blob_url

Create BlobClient from a blob url. This doesn't support customized blob url with '/' in blob name.

from_blob_url(blob_url, credential=None, snapshot=None, **kwargs)

Parameters

blob_url
str
Required

The full endpoint URL to the Blob, including SAS token and snapshot if used. This could be either the primary endpoint, or the secondary endpoint depending on the current location_mode.

credential
Required

The credentials with which to authenticate. This is optional if the account URL already has a SAS token, or the connection string already has shared access key values. The value can be a SAS token string, an account shared access key, or an instance of a TokenCredentials class from azure.identity. Credentials provided here will take precedence over those in the connection string.

snapshot
str
default value: None

The optional blob snapshot on which to operate. This can be the snapshot ID string or the response returned from create_snapshot(metadata=None, **kwargs). If specified, this will override the snapshot in the url.

snapshot
default value: None

Returns

A Blob client.

Return type

from_connection_string

Create BlobClient from a Connection String.

from_connection_string(conn_str, container_name, blob_name, snapshot=None, credential=None, **kwargs)

Parameters

conn_str
str
Required

A connection string to an Azure Storage account.

container_name
str
Required

The container name for the blob.

blob_name
str
Required

The name of the blob with which to interact.

snapshot
str
Required

The optional blob snapshot on which to operate. This can be the snapshot ID string or the response returned from create_snapshot(metadata=None, **kwargs).

credential
default value: None

The credentials with which to authenticate. This is optional if the account URL already has a SAS token, or the connection string already has shared access key values. The value can be a SAS token string, an account shared access key, or an instance of a TokenCredentials class from azure.identity. Credentials provided here will take precedence over those in the connection string.

credential
default value: None

Returns

A Blob client.

Return type

Examples

Creating the BlobClient from a connection string.


   from azure.storage.blob import BlobClient
   blob_client = BlobClient.from_connection_string(
       self.connection_string, container_name="mycontainer", blob_name="blobname.txt")

get_account_information

Gets information related to the storage account in which the blob resides.

The information can also be retrieved if the user has a SAS to a container or blob. The keys in the returned dictionary include 'sku_name' and 'account_kind'.

get_account_information(**kwargs)

Returns

A dict of account information (SKU and account type).

Return type

get_blob_properties

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

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

get_blob_properties(**kwargs)

Parameters

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

BlobProperties

Return type

Examples

Getting the properties for a blob.


   properties = blob_client.get_blob_properties()

get_blob_tags

The Get Tags operation enables users to get tags on a blob or specific blob version, or snapshot.

New in version 12.4.0: This operation was introduced in API version '2019-12-12'.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on destination blob with a matching value.

get_blob_tags(**kwargs)

Parameters

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Key value pairs of blob tags.

Return type

Dict[str, str]

get_block_list

The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on destination blob with a matching value.

New in version 12.4.0.

get_block_list(block_list_type='committed', **kwargs)

Parameters

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

A tuple of two lists - committed and uncommitted blocks

Return type

get_page_range_diff_for_managed_disk

Returns the list of valid page ranges for a managed disk or snapshot.

Note

This operation is only available for managed disk accounts.

New in version 12.2.0: This operation was introduced in API version '2019-07-07'.

get_page_range_diff_for_managed_disk(previous_snapshot_url, offset=None, length=None, **kwargs)

Parameters

previous_snapshot_url
Required

Specifies the URL of a previous snapshot of the managed disk. The response will only contain pages that were changed between the target blob and its previous snapshot.

offset
int
Required

Start of byte range to use for getting valid page ranges. If no length is given, all bytes after the offset will be searched. Pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the length must be a modulus of 512.

length
int
Required

Number of bytes to use for getting valid page ranges. If length is given, offset must be provided. This range will return valid page ranges from the offset start up to the specified length. Pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the length must be a modulus of 512.

lease
BlobLeaseClient or str
Required

Required if the blob has an active lease. Value can be a BlobLeaseClient object or the lease ID as a string.

if_modified_since
datetime
Required

A DateTime value. Azure expects the date value passed in to be UTC. If timezone is included, any non-UTC datetimes will be converted to UTC. If a date is passed in without timezone info, it is assumed to be UTC. Specify this header to perform the operation only if the resource has been modified since the specified time.

if_unmodified_since
datetime
Required

A DateTime value. Azure expects the date value passed in to be UTC. If timezone is included, any non-UTC datetimes will be converted to UTC. If a date is passed in without timezone info, it is assumed to be UTC. Specify this header to perform the operation only if the resource has not been modified since the specified date/time.

etag
str
Required

An ETag value, or the wildcard character (*). Used to check if the resource has changed, and act according to the condition specified by the match_condition parameter.

match_condition
MatchConditions
Required

The match condition to use upon the etag.

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

A tuple of two lists of page ranges as dictionaries with 'start' and 'end' keys. The first element are filled page ranges, the 2nd element is cleared page ranges.

Return type

get_page_ranges

Returns the list of valid page ranges for a Page Blob or snapshot of a page blob.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

get_page_ranges(offset=None, length=None, previous_snapshot_diff=None, **kwargs)

Parameters

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

A tuple of two lists of page ranges as dictionaries with 'start' and 'end' keys. The first element are filled page ranges, the 2nd element is cleared page ranges.

Return type

query_blob

Enables users to select/project on blob/or blob snapshot data by providing simple query expressions. This operations returns a BlobQueryReader, users need to use readall() or readinto() to get query data.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

query_blob(query_expression, **kwargs)

Parameters

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

A streaming object (BlobQueryReader)

Return type

Examples

select/project on blob/or blob snapshot data by providing simple query expressions.


   errors = []
   def on_error(error):
       errors.append(error)

   # upload the csv file
   blob_client = blob_service_client.get_blob_client(container_name, "csvfile")
   with open("./sample-blobs/quick_query.csv", "rb") as stream:
       blob_client.upload_blob(stream, overwrite=True)

   # select the second column of the csv file
   query_expression = "SELECT _2 from BlobStorage"
   input_format = DelimitedTextDialect(delimiter=',', quotechar='"', lineterminator='\n', escapechar="", has_header=False)
   output_format = DelimitedJsonDialect(delimiter='\n')
   reader = blob_client.query_blob(query_expression, on_error=on_error, blob_format=input_format, output_format=output_format)
   content = reader.readall()

resize_blob

Resizes a page blob to the specified size.

If the specified value is less than the current size of the blob, then all pages above the specified value are cleared.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

resize_blob(size, **kwargs)

Parameters

premium_page_blob_tier
PremiumPageBlobTier
Required

A page blob tier value to set the blob to. The tier correlates to the size of the blob and number of allowed IOPS. This is only applicable to page blobs on premium storage accounts.

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Blob-updated property dict (Etag and last modified).

Return type

dict(str, Any)

seal_append_blob

The Seal operation seals the Append Blob to make it read-only.

New in version 12.4.0.

seal_append_blob(**kwargs)

Parameters

appendpos_condition
int
Required

Optional conditional header, used only for the Append Block operation. A number indicating the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 - Precondition Failed).

lease
BlobLeaseClient or str
Required

Required if the blob has an active lease. Value can be a BlobLeaseClient object or the lease ID as a string.

if_modified_since
datetime
Required

A DateTime value. Azure expects the date value passed in to be UTC. If timezone is included, any non-UTC datetimes will be converted to UTC. If a date is passed in without timezone info, it is assumed to be UTC. Specify this header to perform the operation only if the resource has been modified since the specified time.

if_unmodified_since
datetime
Required

A DateTime value. Azure expects the date value passed in to be UTC. If timezone is included, any non-UTC datetimes will be converted to UTC. If a date is passed in without timezone info, it is assumed to be UTC. Specify this header to perform the operation only if the resource has not been modified since the specified date/time.

etag
str
Required

An ETag value, or the wildcard character (*). Used to check if the resource has changed, and act according to the condition specified by the match_condition parameter.

match_condition
MatchConditions
Required

The match condition to use upon the etag.

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Blob-updated property dict (Etag, last modified, append offset, committed block count).

Return type

dict(str, Any)

set_blob_metadata

Sets user-defined metadata for the blob as one or more name-value pairs.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

set_blob_metadata(metadata=None, **kwargs)

Parameters

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

encryption_scope
str
Required

A predefined encryption scope used to encrypt the data on the service. An encryption scope can be created using the Management API and referenced here by name. If a default encryption scope has been defined at the container, this value will override it if the container-level scope is configured to allow overrides. Otherwise an error will be raised.

New in version 12.2.0.

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Blob-updated property dict (Etag and last modified)

set_blob_tags

The Set Tags operation enables users to set tags on a blob or specific blob version, but not snapshot. Each call to this operation replaces all existing tags attached to the blob. To remove all tags from the blob, call this operation with no tags set.

New in version 12.4.0: This operation was introduced in API version '2019-12-12'.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on destination blob with a matching value.

set_blob_tags(tags=None, **kwargs)

Parameters

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Blob-updated property dict (Etag and last modified)

Return type

Dict[str, Any]

set_http_headers

Sets system properties on the blob.

If one property is set for the content_settings, all properties will be overridden.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

set_http_headers(content_settings=None, **kwargs)

Parameters

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Blob-updated property dict (Etag and last modified)

Return type

Dict[str, Any]

set_premium_page_blob_tier

Sets the page blob tiers on the blob. This API is only supported for page blobs on premium accounts.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

set_premium_page_blob_tier(premium_page_blob_tier, **kwargs)

Parameters

timeout
int
Required

The timeout parameter is expressed in seconds. This method may make multiple calls to the Azure service and the timeout will apply to each call individually.

lease
BlobLeaseClient or str
Required

Required if the blob has an active lease. Value can be a BlobLeaseClient object or the lease ID as a string.

Return type

set_sequence_number

Sets the blob sequence number.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

set_sequence_number(sequence_number_action, sequence_number=None, **kwargs)

Parameters

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Blob-updated property dict (Etag and last modified).

Return type

dict(str, Any)

set_standard_blob_tier

This operation sets the tier on a block blob.

A block blob's tier determines Hot/Cool/Archive storage type. This operation does not update the blob's ETag.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

set_standard_blob_tier(standard_blob_tier, **kwargs)

Parameters

timeout
int
Required

The timeout parameter is expressed in seconds.

lease
BlobLeaseClient or str
Required

Required if the blob has an active lease. Value can be a BlobLeaseClient object or the lease ID as a string.

Return type

stage_block

Creates a new block to be committed as part of a blob.

stage_block(block_id, data, length=None, **kwargs)

Parameters

block_id
str
Required

A valid Base64 string value that identifies the block. Prior to encoding, the string must be less than or equal to 64 bytes in size. For a given blob, the length of the value specified for the block_id parameter must be the same size for each block.

data
Required

The blob data.

length
int
Required

Size of the block.

validate_content
bool
Required

If true, calculates an MD5 hash for each chunk of the blob. The storage service checks the hash of the content that has arrived with the hash that was sent. This is primarily valuable for detecting bitflips on the wire if using http instead of https, as https (the default), will already validate. Note that this MD5 hash is not stored with the blob. Also note that if enabled, the memory-efficient upload algorithm will not be used because computing the MD5 hash requires buffering entire blocks, and doing so defeats the purpose of the memory-efficient algorithm.

lease
BlobLeaseClient or str
Required

Required if the blob has an active lease. Value can be a BlobLeaseClient object or the lease ID as a string.

encoding
str
Required

Defaults to UTF-8.

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

encryption_scope
str
Required

A predefined encryption scope used to encrypt the data on the service. An encryption scope can be created using the Management API and referenced here by name. If a default encryption scope has been defined at the container, this value will override it if the container-level scope is configured to allow overrides. Otherwise an error will be raised.

New in version 12.2.0.

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Blob property dict.

Return type

dict[str, Any]

stage_block_from_url

Creates a new block to be committed as part of a blob where the contents are read from a URL.

stage_block_from_url(block_id, source_url, source_offset=None, source_length=None, source_content_md5=None, **kwargs)

Parameters

block_id
str
Required

A valid Base64 string value that identifies the block. Prior to encoding, the string must be less than or equal to 64 bytes in size. For a given blob, the length of the value specified for the block_id parameter must be the same size for each block.

source_url
str
Required

The URL.

source_offset
int
Required

Start of byte range to use for the block. Must be set if source length is provided.

source_length
int
Required

The size of the block in bytes.

source_content_md5
bytearray
Required

Specify the md5 calculated for the range of bytes that must be read from the copy source.

lease
BlobLeaseClient or str
Required

Required if the blob has an active lease. Value can be a BlobLeaseClient object or the lease ID as a string.

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

encryption_scope
str
Required

A predefined encryption scope used to encrypt the data on the service. An encryption scope can be created using the Management API and referenced here by name. If a default encryption scope has been defined at the container, this value will override it if the container-level scope is configured to allow overrides. Otherwise an error will be raised.

New in version 12.2.0.

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Blob property dict.

Return type

dict[str, Any]

start_copy_from_url

Copies a blob asynchronously.

This operation returns a copy operation object that can be used to wait on the completion of the operation, as well as check status or abort the copy operation. The Blob service copies blobs on a best-effort basis.

The source blob for a copy operation may be a block blob, an append blob, or a page blob. If the destination blob already exists, it must be of the same blob type as the source blob. Any existing destination blob will be overwritten. The destination blob cannot be modified while a copy operation is in progress.

When copying from a page blob, the Blob service creates a destination page blob of the source blob's length, initially containing all zeroes. Then the source page ranges are enumerated, and non-empty ranges are copied.

For a block blob or an append blob, the Blob service creates a committed blob of zero length before returning from this operation. When copying from a block blob, all committed blocks and their block IDs are copied. Uncommitted blocks are not copied. At the end of the copy operation, the destination blob will have the same committed block count as the source.

When copying from an append blob, all committed blocks are copied. At the end of the copy operation, the destination blob will have the same committed block count as the source.

For all blob types, you can call status() on the returned polling object to check the status of the copy operation, or wait() to block until the operation is complete. The final blob will be committed when the copy completes.

start_copy_from_url(source_url, metadata=None, incremental_copy=False, **kwargs)

Parameters

source_url
str
Required

A URL of up to 2 KB in length that specifies a file or blob. The value should be URL-encoded as it would appear in a request URI. If the source is in another account, the source must either be public or must be authenticated via a shared access signature. If the source is public, no authentication is required. Examples: https://myaccount.blob.core.windows.net/mycontainer/myblob

https://myaccount.blob.core.windows.net/mycontainer/myblob?snapshot=

https://otheraccount.blob.core.windows.net/mycontainer/myblob?sastoken

metadata
dict(str, str)
Required

Name-value pairs associated with the blob as metadata. If no name-value pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and metadata is not copied from the source blob or file.

incremental_copy
bool
Required

Copies the snapshot of the source page blob to a destination page blob. The snapshot is copied such that only the differential changes between the previously copied snapshot are transferred to the destination. The copied snapshots are complete copies of the original snapshot and can be read or copied from as usual. Defaults to False.

tags
dict(str, str)
Required

Name-value pairs associated with the blob as tag. Tags are case-sensitive. The tag set may contain at most 10 tags. Tag keys must be between 1 and 128 characters, and tag values must be between 0 and 256 characters. Valid tag key and value characters include: lowercase and uppercase letters, digits (0-9), space ( >><<), plus (+), minus (-), period (.), solidus (/), colon (:), equals (=), underscore (_)

New in version 12.4.0.

source_if_modified_since
datetime
Required

A DateTime value. Azure expects the date value passed in to be UTC. If timezone is included, any non-UTC datetimes will be converted to UTC. If a date is passed in without timezone info, it is assumed to be UTC. Specify this conditional header to copy the blob only if the source blob has been modified since the specified date/time.

source_if_unmodified_since
datetime
Required

A DateTime value. Azure expects the date value passed in to be UTC. If timezone is included, any non-UTC datetimes will be converted to UTC. If a date is passed in without timezone info, it is assumed to be UTC. Specify this conditional header to copy the blob only if the source blob has not been modified since the specified date/time.

source_etag
str
Required

The source ETag value, or the wildcard character (*). Used to check if the resource has changed, and act according to the condition specified by the match_condition parameter.

source_match_condition
MatchConditions
Required

The source match condition to use upon the etag.

if_modified_since
datetime
Required

A DateTime value. Azure expects the date value passed in to be UTC. If timezone is included, any non-UTC datetimes will be converted to UTC. If a date is passed in without timezone info, it is assumed to be UTC. Specify this conditional header to copy the blob only if the destination blob has been modified since the specified date/time. If the destination blob has not been modified, the Blob service returns status code 412 (Precondition Failed).

if_unmodified_since
datetime
Required

A DateTime value. Azure expects the date value passed in to be UTC. If timezone is included, any non-UTC datetimes will be converted to UTC. If a date is passed in without timezone info, it is assumed to be UTC. Specify this conditional header to copy the blob only if the destination blob has not been modified since the specified date/time. If the destination blob has been modified, the Blob service returns status code 412 (Precondition Failed).

etag
str
Required

The destination ETag value, or the wildcard character (*). Used to check if the resource has changed, and act according to the condition specified by the match_condition parameter.

match_condition
MatchConditions
Required

The destination match condition to use upon the etag.

destination_lease
BlobLeaseClient or str
Required

The lease ID specified for this header must match the lease ID of the destination blob. If the request does not include the lease ID or it is not valid, the operation fails with status code 412 (Precondition Failed).

source_lease
BlobLeaseClient or str
Required

Specify this to perform the Copy Blob operation only if the lease ID given matches the active lease ID of the source blob.

timeout
int
Required

The timeout parameter is expressed in seconds.

premium_page_blob_tier
PremiumPageBlobTier
Required

A page blob tier value to set the blob to. The tier correlates to the size of the blob and number of allowed IOPS. This is only applicable to page blobs on premium storage accounts.

standard_blob_tier
StandardBlobTier
Required

A standard blob tier value to set the blob to. For this version of the library, this is only applicable to block blobs on standard storage accounts.

rehydrate_priority
RehydratePriority
Required

Indicates the priority with which to rehydrate an archived blob

seal_destination_blob
bool
Required

Seal the destination append blob. This operation is only for append blob.

New in version 12.4.0.

requires_sync
bool
Required

Enforces that the service will not return a response until the copy is complete.

Returns

A dictionary of copy properties (etag, last_modified, copy_id, copy_status).

Return type

Examples

Copy a blob from a URL.


   # Get the blob client with the source blob
   source_blob = "http://www.gutenberg.org/files/59466/59466-0.txt"
   copied_blob = blob_service_client.get_blob_client("copyblobcontainer", '59466-0.txt')

   # start copy and check copy status
   copy = copied_blob.start_copy_from_url(source_blob)
   props = copied_blob.get_blob_properties()
   print(props.copy.status)

undelete_blob

Restores soft-deleted blobs or snapshots.

Operation will only be successful if used within the specified number of days set in the delete retention policy.

undelete_blob(**kwargs)

Parameters

timeout
int
Required

The timeout parameter is expressed in seconds.

Return type

Examples

Undeleting a blob.


   # Undelete the blob before the retention policy expires
   blob_client.undelete_blob()

upload_blob

Creates a new blob from a data source with automatic chunking.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

upload_blob(data, blob_type=<BlobType.BlockBlob: 'BlockBlob'>, length=None, metadata=None, **kwargs)

Parameters

premium_page_blob_tier
PremiumPageBlobTier
Required

A page blob tier value to set the blob to. The tier correlates to the size of the blob and number of allowed IOPS. This is only applicable to page blobs on premium storage accounts.

standard_blob_tier
StandardBlobTier
Required

A standard blob tier value to set the blob to. For this version of the library, this is only applicable to block blobs on standard storage accounts.

maxsize_condition
int
Required

Optional conditional header. The max length in bytes permitted for the append blob. If the Append Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 - Precondition Failed).

max_concurrency
int
Required

Maximum number of parallel connections to use when the blob size exceeds 64MB.

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

encryption_scope
str
Required

A predefined encryption scope used to encrypt the data on the service. An encryption scope can be created using the Management API and referenced here by name. If a default encryption scope has been defined at the container, this value will override it if the container-level scope is configured to allow overrides. Otherwise an error will be raised.

New in version 12.2.0.

encoding
str
Required

Defaults to UTF-8.

timeout
int
Required

The timeout parameter is expressed in seconds. This method may make multiple calls to the Azure service and the timeout will apply to each call individually.

Returns

Blob-updated property dict (Etag and last modified)

Return type

dict[str, Any]

Examples

Upload a blob to the container.


   # Upload content to block blob
   with open(SOURCE_FILE, "rb") as data:
       blob_client.upload_blob(data, blob_type="BlockBlob")

upload_page

The Upload Pages operation writes a range of pages to a page blob.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

upload_page(page, offset, length, **kwargs)

Parameters

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

encryption_scope
str
Required

A predefined encryption scope used to encrypt the data on the service. An encryption scope can be created using the Management API and referenced here by name. If a default encryption scope has been defined at the container, this value will override it if the container-level scope is configured to allow overrides. Otherwise an error will be raised.

New in version 12.2.0.

encoding
str
Required

Defaults to UTF-8.

timeout
int
Required

The timeout parameter is expressed in seconds.

Returns

Blob-updated property dict (Etag and last modified).

Return type

dict(str, Any)

upload_pages_from_url

The Upload Pages operation writes a range of pages to a page blob where the contents are read from a URL.

:keyword str if_tags_match_condition Specify a SQL where clause on blob tags to operate only on blob with a matching value. eg. ""tagname"='my tag'"

New in version 12.4.0.

upload_pages_from_url(source_url, offset, length, source_offset, **kwargs)

Parameters

cpk
CustomerProvidedEncryptionKey
Required

Encrypts the data on the service-side with the given key. Use of customer-provided keys must be done over HTTPS. As the encryption key itself is provided in the request, a secure connection must be established to transfer the key.

encryption_scope
str
Required

A predefined encryption scope used to encrypt the data on the service. An encryption scope can be created using the Management API and referenced here by name. If a default encryption scope has been defined at the container, this value will override it if the container-level scope is configured to allow overrides. Otherwise an error will be raised.

New in version 12.2.0.

timeout
int
Required

The timeout parameter is expressed in seconds.