PageBlobService Class

Page blobs are a collection of 512-byte pages optimized for random read and write operations. To create a page blob, you initialize the page blob and specify the maximum size the page blob will grow. To add or update the contents of a page blob, you write a page or pages by specifying an offset and a range that align to 512-byte page boundaries. A write to a page blob can overwrite just one page, some pages, or up to 4 MB of the page blob. Writes to page blobs happen in-place and are immediately committed to the blob. The maximum size for a page blob is 8 TB.

Inheritance
PageBlobService

Constructor

PageBlobService(account_name=None, account_key=None, sas_token=None, is_emulated=False, protocol='https', endpoint_suffix='core.windows.net', custom_domain=None, request_session=None, connection_string=None, socket_timeout=None, token_credential=None)

Parameters

account_name
default value: None
account_key
default value: None
sas_token
default value: None
is_emulated
default value: False
protocol
default value: https
endpoint_suffix
default value: core.windows.net
custom_domain
default value: None
request_session
default value: None
connection_string
default value: None
socket_timeout
default value: None
token_credential
default value: None

Variables

MAX_PAGE_SIZE
int

The size of the pages put by create_blob_from_* methods. Smaller pages may be put if there is less data provided. The maximum page size the service supports is 4MB. When using the create_blob_from_* methods, empty pages are skipped.

Methods

clear_page

Clears a range of pages.

copy_blob

Copies a blob asynchronously. This operation returns a copy operation properties object, including a copy ID you can use to check or abort the copy operation. The Blob service copies blobs on a best-effort basis.

The source blob for a copy operation must be 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.

If the tier on the source blob is larger than the tier being passed to this copy operation or if the size of the blob exceeds the tier being passed to this copy operation then the operation will fail.

You can call get_blob_properties on the destination blob to check the status of the copy operation. The final blob will be committed when the copy completes.

create_blob

Creates a new Page Blob.

See create_blob_from_* for high level functions that handle the creation and upload of large blobs with automatic chunking and progress notifications.

create_blob_from_bytes

Creates a new blob from an array of bytes, or updates the content of an existing blob, with automatic chunking and progress notifications. Empty chunks are skipped, while non-emtpy ones(even if only partly filled) are uploaded.

create_blob_from_path

Creates a new blob from a file path, or updates the content of an existing blob, with automatic chunking and progress notifications. Empty chunks are skipped, while non-emtpy ones(even if only partly filled) are uploaded.

create_blob_from_stream

Creates a new blob from a file/stream, or updates the content of an existing blob, with automatic chunking and progress notifications. Empty chunks are skipped, while non-emtpy ones(even if only partly filled) are uploaded.

get_page_ranges

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

get_page_ranges_diff

The response will include only the pages that are different between either a recent snapshot or the current blob and a previous snapshot, including pages that were cleared.

incremental_copy_blob

Copies an incremental copy of a blob asynchronously. This operation returns a copy operation properties object, including a copy ID you can use to check or abort the copy operation. The Blob service copies blobs on a best-effort basis.

The source blob for an incremental copy operation must be a page blob. Call get_blob_properties on the destination blob to check the status of the copy operation. The final blob will be committed when the copy completes.

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.

set_premium_page_blob_tier

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

set_sequence_number

Sets the blob sequence number.

update_page

Updates a range of pages.

clear_page

Clears a range of pages.

clear_page(container_name, blob_name, start_range, end_range, lease_id=None, if_sequence_number_lte=None, if_sequence_number_lt=None, if_sequence_number_eq=None, if_modified_since=None, if_unmodified_since=None, if_match=None, if_none_match=None, timeout=None)

Parameters

container_name
str
Required

Name of existing container.

blob_name
str
Required

Name of existing blob.

start_range
int
Required

Start of byte range to use for writing to a section of the blob. Pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512-1. Examples of valid byte ranges are 0-511, 512-1023, etc.

end_range
int
Required

End of byte range to use for writing to a section of the blob. Pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512-1. Examples of valid byte ranges are 0-511, 512-1023, etc.

lease_id
str
default value: None

Required if the blob has an active lease.

if_sequence_number_lte
int
default value: None

If the blob's sequence number is less than or equal to the specified value, the request proceeds; otherwise it fails.

if_sequence_number_lt
int
default value: None

If the blob's sequence number is less than the specified value, the request proceeds; otherwise it fails.

if_sequence_number_eq
int
default value: None

If the blob's sequence number is equal to the specified value, the request proceeds; otherwise it fails.

if_modified_since
datetime
default value: None

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
default value: None

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.

if_match
str
default value: None

An ETag value, or the wildcard character (*). Specify an ETag value for this conditional header to write the page only if the blob's ETag value matches the value specified. If the values do not match, the Blob service fails.

if_none_match
str
default value: None

An ETag value, or the wildcard character (*). Specify an ETag value for this conditional header to write the page only if the blob's ETag value does not match the value specified. If the values are identical, the Blob service fails.

timeout
int
default value: None

The timeout parameter is expressed in seconds.

Returns

ETag and last modified properties for the updated Page Blob

Return type

copy_blob

Copies a blob asynchronously. This operation returns a copy operation properties object, including a copy ID you can use to check or abort the copy operation. The Blob service copies blobs on a best-effort basis.

The source blob for a copy operation must be 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.

If the tier on the source blob is larger than the tier being passed to this copy operation or if the size of the blob exceeds the tier being passed to this copy operation then the operation will fail.

You can call get_blob_properties on the destination blob to check the status of the copy operation. The final blob will be committed when the copy completes.

copy_blob(container_name, blob_name, copy_source, metadata=None, source_if_modified_since=None, source_if_unmodified_since=None, source_if_match=None, source_if_none_match=None, destination_if_modified_since=None, destination_if_unmodified_since=None, destination_if_match=None, destination_if_none_match=None, destination_lease_id=None, source_lease_id=None, timeout=None, premium_page_blob_tier=None)

Parameters

container_name
str
Required

Name of the destination container. The container must exist.

blob_name
str
Required

Name of the destination blob. If the destination blob exists, it will be overwritten. Otherwise, it will be created.

copy_source
str
Required

A URL of up to 2 KB in length that specifies an Azure 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)
default value: None

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.

source_if_modified_since
datetime
default value: None

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
default value: None

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_if_match
<xref:ETag>
default value: None

An ETag value, or the wildcard character (*). Specify this conditional header to copy the source blob only if its ETag matches the value specified. If the ETag values do not match, the Blob service returns status code 412 (Precondition Failed). This header cannot be specified if the source is an Azure File.

source_if_none_match
<xref:ETag>
default value: None

An ETag value, or the wildcard character (*). Specify this conditional header to copy the blob only if its ETag does not match the value specified. If the values are identical, the Blob service returns status code 412 (Precondition Failed). This header cannot be specified if the source is an Azure File.

destination_if_modified_since
datetime
default value: None

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).

destination_if_unmodified_since
datetime
default value: None

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).

destination_if_match
<xref:ETag>
default value: None

An ETag value, or the wildcard character (*). Specify an ETag value for this conditional header to copy the blob only if the specified ETag value matches the ETag value for an existing destination blob. If the ETag for the destination blob does not match the ETag specified for If-Match, the Blob service returns status code 412 (Precondition Failed).

destination_if_none_match
<xref:ETag>
default value: None

An ETag value, or the wildcard character (). Specify an ETag value for this conditional header to copy the blob only if the specified ETag value does not match the ETag value for the destination blob. Specify the wildcard character () to perform the operation only if the destination blob does not exist. If the specified condition isn't met, the Blob service returns status code 412 (Precondition Failed).

destination_lease_id
str
default value: None

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_id
str
default value: None

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
default value: None

The timeout parameter is expressed in seconds.

premium_page_blob_tier
<xref:PageBlobTier>
default value: None

A page blob tier value to set on the destination blob. 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. If the tier on the source blob is larger than the tier being passed to this copy operation or if the size of the blob exceeds the tier being passed to this copy operation then the operation will fail.

Returns

Copy operation properties such as status, source, and ID.

Return type

create_blob

Creates a new Page Blob.

See create_blob_from_* for high level functions that handle the creation and upload of large blobs with automatic chunking and progress notifications.

create_blob(container_name, blob_name, content_length, content_settings=None, sequence_number=None, metadata=None, lease_id=None, if_modified_since=None, if_unmodified_since=None, if_match=None, if_none_match=None, timeout=None, premium_page_blob_tier=None)

Parameters

container_name
str
Required

Name of existing container.

blob_name
str
Required

Name of blob to create or update.

content_length
int
Required

Required. This header 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
default value: None

ContentSettings object used to set properties on the blob.

sequence_number
int
default value: None

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.

metadata
dict(str, str)
default value: None

Name-value pairs associated with the blob as metadata.

lease_id
str
default value: None

Required if the blob has an active lease.

if_modified_since
datetime
default value: None

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
default value: None

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.

if_match
str
default value: None

An ETag value, or the wildcard character (*). Specify this header to perform the operation only if the resource's ETag matches the value specified.

if_none_match
str
default value: None

An ETag value, or the wildcard character (). Specify this header to perform the operation only if the resource's ETag does not match the value specified. Specify the wildcard character () to perform the operation only if the resource does not exist, and fail the operation if it does exist.

timeout
int
default value: None

The timeout parameter is expressed in seconds.

premium_page_blob_tier
PremiumPageBlobTier
default value: None

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.

Returns

ETag and last modified properties for the new Page Blob

Return type

create_blob_from_bytes

Creates a new blob from an array of bytes, or updates the content of an existing blob, with automatic chunking and progress notifications. Empty chunks are skipped, while non-emtpy ones(even if only partly filled) are uploaded.

create_blob_from_bytes(container_name, blob_name, blob, index=0, count=None, content_settings=None, metadata=None, validate_content=False, progress_callback=None, max_connections=2, lease_id=None, if_modified_since=None, if_unmodified_since=None, if_match=None, if_none_match=None, timeout=None, premium_page_blob_tier=None)

Parameters

container_name
str
Required

Name of existing container.

blob_name
str
Required

Name of blob to create or update.

blob
bytes
Required

Content of blob as an array of bytes.

index
int
default value: 0

Start index in the byte array.

count
int
default value: None

Number of bytes to upload. Set to None or negative value to upload all bytes starting from index.

content_settings
ContentSettings
default value: None

ContentSettings object used to set blob properties.

metadata
dict(str, str)
default value: None

Name-value pairs associated with the blob as metadata.

validate_content
bool
default value: False

If true, calculates an MD5 hash for each page 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.

progress_callback
<xref:func>(<xref:current>, <xref:total>)
default value: None

Callback for progress with signature function(current, total) where current is the number of bytes transfered so far, and total is the size of the blob, or None if the total size is unknown.

max_connections
int
default value: 2

Maximum number of parallel connections to use.

lease_id
str
default value: None

Required if the blob has an active lease.

if_modified_since
datetime
default value: None

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
default value: None

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.

if_match
str
default value: None

An ETag value, or the wildcard character (*). Specify this header to perform the operation only if the resource's ETag matches the value specified.

if_none_match
str
default value: None

An ETag value, or the wildcard character (). Specify this header to perform the operation only if the resource's ETag does not match the value specified. Specify the wildcard character () to perform the operation only if the resource does not exist, and fail the operation if it does exist.

timeout
int
default value: None

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.

premium_page_blob_tier
default value: None

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.

Returns

ETag and last modified properties for the Page Blob

Return type

create_blob_from_path

Creates a new blob from a file path, or updates the content of an existing blob, with automatic chunking and progress notifications. Empty chunks are skipped, while non-emtpy ones(even if only partly filled) are uploaded.

create_blob_from_path(container_name, blob_name, file_path, content_settings=None, metadata=None, validate_content=False, progress_callback=None, max_connections=2, lease_id=None, if_modified_since=None, if_unmodified_since=None, if_match=None, if_none_match=None, timeout=None, premium_page_blob_tier=None)

Parameters

container_name
str
Required

Name of existing container.

blob_name
str
Required

Name of blob to create or update.

file_path
str
Required

Path of the file to upload as the blob content.

content_settings
ContentSettings
default value: None

ContentSettings object used to set blob properties.

metadata
dict(str, str)
default value: None

Name-value pairs associated with the blob as metadata.

validate_content
bool
default value: False

If true, calculates an MD5 hash for each page 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.

progress_callback
<xref:func>(<xref:current>, <xref:total>)
default value: None

Callback for progress with signature function(current, total) where current is the number of bytes transfered so far, and total is the size of the blob, or None if the total size is unknown.

max_connections
int
default value: 2

Maximum number of parallel connections to use.

lease_id
str
default value: None

Required if the blob has an active lease.

if_modified_since
datetime
default value: None

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
default value: None

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.

if_match
str
default value: None

An ETag value, or the wildcard character (*). Specify this header to perform the operation only if the resource's ETag matches the value specified.

if_none_match
str
default value: None

An ETag value, or the wildcard character (). Specify this header to perform the operation only if the resource's ETag does not match the value specified. Specify the wildcard character () to perform the operation only if the resource does not exist, and fail the operation if it does exist.

timeout
int
default value: None

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.

premium_page_blob_tier
default value: None

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.

Returns

ETag and last modified properties for the Page Blob

Return type

create_blob_from_stream

Creates a new blob from a file/stream, or updates the content of an existing blob, with automatic chunking and progress notifications. Empty chunks are skipped, while non-emtpy ones(even if only partly filled) are uploaded.

create_blob_from_stream(container_name, blob_name, stream, count, content_settings=None, metadata=None, validate_content=False, progress_callback=None, max_connections=2, lease_id=None, if_modified_since=None, if_unmodified_since=None, if_match=None, if_none_match=None, timeout=None, premium_page_blob_tier=None)

Parameters

container_name
str
Required

Name of existing container.

blob_name
str
Required

Name of blob to create or update.

stream
IOBase
Required

Opened file/stream to upload as the blob content.

count
int
Required

Number of bytes to read from the stream. This is required, a page blob cannot be created if the count is unknown.

content_settings
ContentSettings
default value: None

ContentSettings object used to set the blob properties.

metadata
dict(str, str)
default value: None

Name-value pairs associated with the blob as metadata.

validate_content
bool
default value: False

If true, calculates an MD5 hash for each page 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.

progress_callback
<xref:func>(<xref:current>, <xref:total>)
default value: None

Callback for progress with signature function(current, total) where current is the number of bytes transfered so far, and total is the size of the blob, or None if the total size is unknown.

max_connections
int
default value: 2

Maximum number of parallel connections to use. Note that parallel upload requires the stream to be seekable.

lease_id
str
default value: None

Required if the blob has an active lease.

if_modified_since
datetime
default value: None

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
default value: None

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.

if_match
str
default value: None

An ETag value, or the wildcard character (*). Specify this header to perform the operation only if the resource's ETag matches the value specified.

if_none_match
str
default value: None

An ETag value, or the wildcard character (). Specify this header to perform the operation only if the resource's ETag does not match the value specified. Specify the wildcard character () to perform the operation only if the resource does not exist, and fail the operation if it does exist.

timeout
int
default value: None

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.

premium_page_blob_tier
default value: None

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.

Returns

ETag and last modified properties for the Page Blob

Return type

get_page_ranges

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

get_page_ranges(container_name, blob_name, snapshot=None, start_range=None, end_range=None, lease_id=None, if_modified_since=None, if_unmodified_since=None, if_match=None, if_none_match=None, timeout=None)

Parameters

container_name
str
Required

Name of existing container.

blob_name
str
Required

Name of existing blob.

snapshot
str
default value: None

The snapshot parameter is an opaque DateTime value that, when present, specifies the blob snapshot to retrieve information from.

start_range
int
default value: None

Start of byte range to use for getting valid page ranges. If no end_range is given, all bytes after the start_range will be searched. Pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512-1. Examples of valid byte ranges are 0-511, 512-, etc.

end_range
int
default value: None

End of byte range to use for getting valid page ranges. If end_range is given, start_range must be provided. This range will return valid page ranges for from the offset start up to offset end. Pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512-1. Examples of valid byte ranges are 0-511, 512-, etc.

lease_id
str
default value: None

Required if the blob has an active lease.

if_modified_since
datetime
default value: None

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
default value: None

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.

if_match
str
default value: None

An ETag value, or the wildcard character (*). Specify this header to perform the operation only if the resource's ETag matches the value specified.

if_none_match
str
default value: None

An ETag value, or the wildcard character (). Specify this header to perform the operation only if the resource's ETag does not match the value specified. Specify the wildcard character () to perform the operation only if the resource does not exist, and fail the operation if it does exist.

timeout
int
default value: None

The timeout parameter is expressed in seconds.

Returns

A list of valid Page Ranges for the Page Blob.

Return type

get_page_ranges_diff

The response will include only the pages that are different between either a recent snapshot or the current blob and a previous snapshot, including pages that were cleared.

get_page_ranges_diff(container_name, blob_name, previous_snapshot, snapshot=None, start_range=None, end_range=None, lease_id=None, if_modified_since=None, if_unmodified_since=None, if_match=None, if_none_match=None, timeout=None)

Parameters

container_name
str
Required

Name of existing container.

blob_name
str
Required

Name of existing blob.

previous_snapshot
str
Required

The snapshot parameter is an opaque DateTime value that specifies a previous blob snapshot to be compared against a more recent snapshot or the current blob.

snapshot
str
default value: None

The snapshot parameter is an opaque DateTime value that specifies a more recent blob snapshot to be compared against a previous snapshot (previous_snapshot).

start_range
int
default value: None

Start of byte range to use for getting different page ranges. If no end_range is given, all bytes after the start_range will be searched. Pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512-1. Examples of valid byte ranges are 0-511, 512-, etc.

end_range
int
default value: None

End of byte range to use for getting different page ranges. If end_range is given, start_range must be provided. This range will return valid page ranges for from the offset start up to offset end. Pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512-1. Examples of valid byte ranges are 0-511, 512-, etc.

lease_id
str
default value: None

Required if the blob has an active lease.

if_modified_since
datetime
default value: None

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
default value: None

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.

if_match
str
default value: None

An ETag value, or the wildcard character (*). Specify this header to perform the operation only if the resource's ETag matches the value specified.

if_none_match
str
default value: None

An ETag value, or the wildcard character (). Specify this header to perform the operation only if the resource's ETag does not match the value specified. Specify the wildcard character () to perform the operation only if the resource does not exist, and fail the operation if it does exist.

timeout
int
default value: None

The timeout parameter is expressed in seconds.

Returns

A list of different Page Ranges for the Page Blob.

Return type

incremental_copy_blob

Copies an incremental copy of a blob asynchronously. This operation returns a copy operation properties object, including a copy ID you can use to check or abort the copy operation. The Blob service copies blobs on a best-effort basis.

The source blob for an incremental copy operation must be a page blob. Call get_blob_properties on the destination blob to check the status of the copy operation. The final blob will be committed when the copy completes.

incremental_copy_blob(container_name, blob_name, copy_source, metadata=None, destination_if_modified_since=None, destination_if_unmodified_since=None, destination_if_match=None, destination_if_none_match=None, destination_lease_id=None, source_lease_id=None, timeout=None)

Parameters

container_name
str
Required

Name of the destination container. The container must exist.

blob_name
str
Required

Name of the destination blob. If the destination blob exists, it will be overwritten. Otherwise, it will be created.

copy_source
str
Required

A URL of up to 2 KB in length that specifies an Azure page blob. The value should be URL-encoded as it would appear in a request URI. The copy source must be a snapshot and include a valid SAS token or be public. Example: https://myaccount.blob.core.windows.net/mycontainer/myblob?snapshot=&sastoken

metadata
dict(str, str)
default value: None

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.

destination_if_modified_since
datetime
default value: None

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).

destination_if_unmodified_since
datetime
default value: None

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 ate/time. If the destination blob has been modified, the Blob service returns status code 412 (Precondition Failed).

destination_if_match
<xref:ETag>
default value: None

An ETag value, or the wildcard character (*). Specify an ETag value for this conditional header to copy the blob only if the specified ETag value matches the ETag value for an existing destination blob. If the ETag for the destination blob does not match the ETag specified for If-Match, the Blob service returns status code 412 (Precondition Failed).

destination_if_none_match
<xref:ETag>
default value: None

An ETag value, or the wildcard character (). Specify an ETag value for this conditional header to copy the blob only if the specified ETag value does not match the ETag value for the destination blob. Specify the wildcard character () to perform the operation only if the destination blob does not exist. If the specified condition isn't met, the Blob service returns status code 412 (Precondition Failed).

destination_lease_id
str
default value: None

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_id
str
default value: None

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
default value: None

The timeout parameter is expressed in seconds.

Returns

Copy operation properties such as status, source, and ID.

Return type

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.

resize_blob(container_name, blob_name, content_length, lease_id=None, if_modified_since=None, if_unmodified_since=None, if_match=None, if_none_match=None, timeout=None)

Parameters

container_name
str
Required

Name of existing container.

blob_name
str
Required

Name of existing blob.

content_length
int
Required

Size to resize blob to.

lease_id
str
default value: None

Required if the blob has an active lease.

if_modified_since
datetime
default value: None

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
default value: None

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.

if_match
str
default value: None

An ETag value, or the wildcard character (*). Specify this header to perform the operation only if the resource's ETag matches the value specified.

if_none_match
str
default value: None

An ETag value, or the wildcard character (). Specify this header to perform the operation only if the resource's ETag does not match the value specified. Specify the wildcard character () to perform the operation only if the resource does not exist, and fail the operation if it does exist.

timeout
int
default value: None

The timeout parameter is expressed in seconds.

Returns

ETag and last modified properties for the updated Page Blob

Return type

set_premium_page_blob_tier

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

set_premium_page_blob_tier(container_name, blob_name, premium_page_blob_tier, timeout=None)

Parameters

container_name
str
Required

Name of existing container.

blob_name
str
Required

Name of blob to update.

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
default value: None

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.

set_sequence_number

Sets the blob sequence number.

set_sequence_number(container_name, blob_name, sequence_number_action, sequence_number=None, lease_id=None, if_modified_since=None, if_unmodified_since=None, if_match=None, if_none_match=None, timeout=None)

Parameters

container_name
str
Required

Name of existing container.

blob_name
str
Required

Name of existing blob.

sequence_number_action
str
Required

This property indicates how the service should modify the blob's sequence number. See SequenceNumberAction for more information.

sequence_number
str
default value: None

This property sets the blob's sequence number. The sequence number is a user-controlled property that you can use to track requests and manage concurrency issues.

lease_id
str
default value: None

Required if the blob has an active lease.

if_modified_since
datetime
default value: None

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
default value: None

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.

if_match
str
default value: None

An ETag value, or the wildcard character (*). Specify this header to perform the operation only if the resource's ETag matches the value specified.

if_none_match
str
default value: None

An ETag value, or the wildcard character (). Specify this header to perform the operation only if the resource's ETag does not match the value specified. Specify the wildcard character () to perform the operation only if the resource does not exist, and fail the operation if it does exist.

timeout
int
default value: None

The timeout parameter is expressed in seconds.

Returns

ETag and last modified properties for the updated Page Blob

Return type

update_page

Updates a range of pages.

update_page(container_name, blob_name, page, start_range, end_range, validate_content=False, lease_id=None, if_sequence_number_lte=None, if_sequence_number_lt=None, if_sequence_number_eq=None, if_modified_since=None, if_unmodified_since=None, if_match=None, if_none_match=None, timeout=None)

Parameters

container_name
str
Required

Name of existing container.

blob_name
str
Required

Name of existing blob.

page
bytes
Required

Content of the page.

start_range
int
Required

Start of byte range to use for writing to a section of the blob. Pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512-1. Examples of valid byte ranges are 0-511, 512-1023, etc.

end_range
int
Required

End of byte range to use for writing to a section of the blob. Pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512-1. Examples of valid byte ranges are 0-511, 512-1023, etc.

validate_content
bool
default value: False

If true, calculates an MD5 hash of the page content. 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.

lease_id
str
default value: None

Required if the blob has an active lease.

if_sequence_number_lte
int
default value: None

If the blob's sequence number is less than or equal to the specified value, the request proceeds; otherwise it fails.

if_sequence_number_lt
int
default value: None

If the blob's sequence number is less than the specified value, the request proceeds; otherwise it fails.

if_sequence_number_eq
int
default value: None

If the blob's sequence number is equal to the specified value, the request proceeds; otherwise it fails.

if_modified_since
datetime
default value: None

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
default value: None

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.

if_match
str
default value: None

An ETag value, or the wildcard character (*). Specify an ETag value for this conditional header to write the page only if the blob's ETag value matches the value specified. If the values do not match, the Blob service fails.

if_none_match
str
default value: None

An ETag value, or the wildcard character (*). Specify an ETag value for this conditional header to write the page only if the blob's ETag value does not match the value specified. If the values are identical, the Blob service fails.

timeout
int
default value: None

The timeout parameter is expressed in seconds.

Returns

ETag and last modified properties for the updated Page Blob

Return type

Attributes

MAX_PAGE_SIZE

MAX_PAGE_SIZE = 4194304