Append Block From URL

The Append Block From URL operation commits a new block of data to the end of an existing append blob.

The Append Block From URL operation is permitted only if the blob was created with x-ms-blob-type set to AppendBlob. Append Block From URL is supported only on version 2018-11-09 version or later.

Request

You can construct the Append Block From URL request as follows. HTTPS is recommended. Replace myaccount with the name of your storage account.

PUT method request URI HTTP version
https://myaccount.blob.core.windows.net/mycontainer/myblob?comp=appendblock HTTP/1.1

When you're making a request against the emulated storage service, specify the emulator hostname and Azure Blob Storage port as 127.0.0.1:10000, followed by the emulated storage account name.

PUT method request URI HTTP version
http://127.0.0.1:10000/devstoreaccount1/mycontainer/myblob?comp=appendblock HTTP/1.1

For more information, see Use the Azurite emulator for local Azure Storage development.

URI parameters

Parameter Description
timeout Optional. The timeout parameter is expressed in seconds. For more information, see Setting timeouts for Blob Storage operations.

Request headers

The following table describes required and optional request headers.

Request header Description
Authorization Required. Specifies the authorization scheme, account name, and signature. See Authorize requests to Azure Storage for more information.
Date or x-ms-date Required. Specifies the Coordinated Universal Time (UTC) for the request. For more information, see Authorize requests to Azure Storage.
x-ms-version Required for all authorized requests. Specifies the version of the operation to use for this request. For more information, see Versioning for the Azure Storage services.
Content-Length Required. Specifies the number of bytes being transmitted in the request body. The value of this header must be set to zero. When the length is not zero, the operation will fail with error code 400 (Bad Request).
x-ms-copy-source:name Required. Specifies the URL of the source blob. The value can be a URL of up to 2 KiB in length that specifies a blob. The value should be URL-encoded, as it would appear in a request URI. The source blob must either be public or must be authorized via a shared access signature. If the source blob is public, no authorization is required to perform the operation. Here are some examples of source object URLs:

https://myaccount.blob.core.windows.net/mycontainer/myblob
https://myaccount.blob.core.windows.net/mycontainer/myblob?snapshot=<DateTime>
https://myaccount.blob.core.windows.net/mycontainer/myblob?versionid=<DateTime>
x-ms-copy-source-authorization: <scheme> <signature> Optional. Specifies the authorization scheme and signature for copy source. For more information, see Authorize requests to Azure Storage.
Only scheme bearer is supported for Microsoft Entra ID.
This header is supported in version 2020-10-02 and later.
x-ms-source-range Optional. Uploads only the bytes of the blob in the source URL in the specified range. If this isn't specified, the entire source blob contents are uploaded as a single append block. See Specifying the range header for Blob Storage operations for more information.
x-ms-source-content-md5 Optional. An MD5 hash of the append block content from the URI. This hash is used to verify the integrity of the append block during transport of the data from the URI. When you specify this header, the storage service compares the hash of the content that has arrived from the copy-source with this header value.

Note that this MD5 hash isn't stored with the blob.

If the two hashes don't match, the operation fails with error code 400 (Bad Request).
x-ms-source-content-crc64 Optional. A CRC64 hash of the append block content from the URI. This hash is used to verify the integrity of the append block during transport of the data from the URI. When you specify this header, the storage service compares the hash of the content that has arrived from the copy-source with this header value.

Note that this CRC64 hash isn't stored with the blob.

If the two hashes don't match, the operation fails with error code 400 (Bad Request).

If both x-ms-source-content-md5 and x-ms-source-content-crc64 headers are present, the request fails with a 400 (Bad Request).

This header is supported in version 2019-02-02 or later.
x-ms-encryption-scope Optional. Indicates the encryption scope to use to encrypt the source contents. This header is supported in version 2019-02-02 or later.
x-ms-lease-id:<ID> Required if the blob has an active lease. To perform this operation on a blob with an active lease, specify the valid lease ID for this header.
x-ms-client-request-id Optional. Provides a client-generated, opaque value with a 1-kibibyte (KiB) character limit that's recorded in the logs when logging is configured. We highly recommend that you use this header to correlate client-side activities with requests that the server receives. For more information, see Monitor Azure Blob Storage.
x-ms-blob-condition-maxsize Optional conditional header. The maximum length in bytes permitted for the append blob. If the Append Block From URL operation causes the blob to exceed that limit, or if the blob size is already greater than the value specified in this header, the request fails with a 412 (Precondition Failed).
x-ms-blob-condition-appendpos Optional conditional header, used only for the Append Block from URL operation. A number indicating the byte offset to compare. Append Block from URL succeeds only if the append position is equal to this number. If it isn't, the request fails with a 412 (Precondition Failed).

This operation supports the use of additional, conditional headers, to ensure that the API succeeds only if a specified condition is met. For more information, see Specifying conditional headers for Blob Storage operations.

Request headers (customer-provided encryption keys)

Beginning with version 2019-02-02, you can specify the following headers on the request to encrypt a blob with a customer-provided key. Encryption with a customer-provided key (and the corresponding set of headers) is optional.

Request header Description
x-ms-encryption-key Required. The Base64-encoded AES-256 encryption key.
x-ms-encryption-key-sha256 Required. The Base64-encoded SHA256 hash of the encryption key.
x-ms-encryption-algorithm: AES256 Required. Specifies the algorithm to use for encryption. The value of this header must be AES256.

Request body

The request body contains the content of the block.

Sample request

Request Syntax:  
PUT https://myaccount.blob.core.windows.net/mycontainer/myblob?comp=appendblock  HTTP/1.1  

Request Headers:  
x-ms-version: 2018-11-09  
x-ms-date: <date>  
x-ms-copy-source: https://myaccount.blob.core.windows.net/mycontainer/myblob
x-ms-source-range: bytes=0-65535
x-ms-blob-condition-appendpos: 2097152  
x-ms-blob-condition-maxsize: 4194304  
Authorization: SharedKey myaccount:J4ma1VuFnlJ7yfk/Gu1GxzbfdJloYmBPWlfhZ/xn7GI=  
Content-Length: 0 
If-Match: "0x8CB172A360EC34B"  

Response

The response includes an HTTP status code and a set of response headers.

Status code

A successful operation returns status code 201 (Created). For information about status codes, see Status and error codes.

Response headers

The response for this operation includes the following headers. The response can also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.

Response header Description
Etag The ETag contains a value in quotes. The client uses the value to perform conditional PUT operations by using the If-Match request header.
Last-Modified The date/time that the blob was last modified. The date format follows RFC 1123. For more information, see Representation of date-time values in headers.

Any write operation on the blob (including updates on the blob's metadata or properties) changes the last-modified time of the blob.
Content-MD5 This header is returned so that the client can check for message content integrity. Blob Storage computes the value of this header. It isn't necessarily the same value specified in the request headers. For version 2019-02-02 or later, this header is only returned when the request has this header.
x-ms-content-crc64 For version 2019-02-02 or later. This header is returned so that the client can check for message content integrity. Blob Storage computes the value of this header. It isn't necessarily the same value specified in the request headers.

This header is returned when the x-ms-source-content-md5 header isn't present in the request.
x-ms-request-id This header uniquely identifies the request that was made, and can be used for troubleshooting the request.
x-ms-version Indicates the version of Blob Storage used to run the request. This header is returned for requests made against version 2009-09-19 and later.
Date A UTC date/time value generated by the service that indicates the time at which the response was initiated.
x-ms-blob-append-offset This response header is returned only for append operations. It returns the offset at which the block was committed, in bytes.
x-ms-blob-committed-block-count The number of committed blocks present in the blob. You can use this to control how many more appends can be done.
x-ms-request-server-encrypted: true/false Version 2015-12-11 or later. The value of this header is set to true if the contents of the request are successfully encrypted by using the specified algorithm. Otherwise, the value is set to false.
x-ms-encryption-key-sha256 Version 2019-02-02 or later. This header is returned if the request used a customer-provided key for encryption. The client can then ensure that the contents of the request are successfully encrypted by using the provided key.
x-ms-encryption-scope Version 2019-02-02 or later. This header is returned if the request used an encryption scope. The client can then ensure that the contents of the request are successfully encrypted by using the encryption scope.

Sample response

Response Status:  
HTTP/1.1 201 Created  

Response Headers:  
Transfer-Encoding: chunked  
x-ms-content-crc64: 77uWZTolTHU  
Date: <date>  
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0  
x-ms-blob-append-offset: 2097152  
x-ms-blob-committed–block-count: 1000  

Authorization

Authorization is required when calling any data access operation in Azure Storage. You can authorize the Append Block From URL operation as described below.

The authorization details in this section apply to the copy destination. For more information on copy source authorization, see the details for the request header x-ms-copy-source.

Important

Microsoft recommends using Microsoft Entra ID with managed identities to authorize requests to Azure Storage. Microsoft Entra ID provides superior security and ease of use compared to Shared Key authorization.

Azure Storage supports using Microsoft Entra ID to authorize requests to blob data. With Microsoft Entra ID, you can use Azure role-based access control (Azure RBAC) to grant permissions to a security principal. The security principal may be a user, group, application service principal, or Azure managed identity. The security principal is authenticated by Microsoft Entra ID to return an OAuth 2.0 token. The token can then be used to authorize a request against the Blob service.

To learn more about authorization using Microsoft Entra ID, see Authorize access to blobs using Microsoft Entra ID.

Permissions

Listed below are the RBAC action necessary for a Microsoft Entra user, group, managed identity, or service principal to call the Append Block From URL operation, and the least privileged built-in Azure RBAC role that includes this action:

To learn more about assigning roles using Azure RBAC, see Assign an Azure role for access to blob data.

Remarks

Append Block From URL uploads a block to the end of an existing append blob. The block of data is immediately available after the call succeeds on the server. A maximum of 50,000 appends are permitted for each append blob, where. Each block can be of different size.

The following table describes the maximum permitted block and blob sizes, by service version:

Service version Maximum block size (via Append Block From URL) Maximum blob size
Version 2022-11-02 and later 100 MiB (Preview) Approximately 4.75 TiB (100 MiB × 50,000 blocks)
Versions earlier than 2022-11-02 4 MiB Approximately 195 gibibytes (GiB) (4 MiB × 50,000 blocks)

In version 2020-10-02 and later, Microsoft Entra ID authorization is supported for the source of the copy operation.

Append Block From URL succeeds only if the blob already exists.

Blobs uploaded by using Append Block From URL don't expose block IDs, so you can't call Get Block List against an append blob. Doing so results in an error.

You can specify the following optional, conditional headers on the request:

  • x-ms-blob-condition-appendpos: You can set this header to a byte offset at which the client expects to append the block. The request succeeds only if the current offset matches that specified by the client. Otherwise, the request fails with error code 412 (Precondition Failed).

    Clients that use a single writer can use this header to determine whether when an Append Block From URL operation succeeded, despite network failure.

  • x-ms-blob-condition-maxsize: Clients can use this header to ensure that append operations don't increase the blob size beyond an expected maximum size in bytes. If the condition fails, the request fails with error code 412 (Precondition Failed).

If you attempt to upload a block that is larger than the permitted size, the service returns HTTP error code 413 (Request Entity Too Large). The service also returns additional information about the error in the response, including the maximum block size permitted in bytes. If you attempt to upload more than 50,000 blocks, the service returns error code 409 (Conflict).

If the blob has an active lease, the client must specify a valid lease ID on the request in order to write a block to the blob. If the client doesn't specify a lease ID, or specifies an invalid lease ID, Blob Storage returns error code 412 (Precondition Failed). If the client specifies a lease ID but the blob doesn't have an active lease, the service returns error code 412.

If you call Append Block From URL on an existing block blob or page blob, the service returns error code 409 (Conflict). If you call Append Block From URL on a non-existent blob, the service returns error code 404 (Not Found).

Avoid duplicate or delayed appends

In a single writer scenario, the client can avoid duplicate appends or delayed writes by using the x-ms-blob-condition-appendpos conditional header to check the current offset. The client can also avoid duplicates or delays by checking the ETag conditionally, by using If-Match.

In a multiple writer scenario, each client can use conditional headers. This might not be optimal for performance. For the highest concurrent append throughput, applications should handle redundant appends and delayed appends in their application layer. For example, applications can add epochs or sequence numbers in the data being appended.

To learn about pricing for the specified billing category, see Azure Blob Storage Pricing.

Billing

Pricing requests can originate from clients that use Blob Storage APIs, either directly through the Blob Storage REST API, or from an Azure Storage client library. These requests accrue charges per transaction. The type of transaction affects how the account is charged. For example, read transactions accrue to a different billing category than write transactions. The following table shows the billing category for Append Block From URL requests based on the storage account type:

Operation Storage account type Billing category
Append Block From URL (destination account1) Premium block blob
Standard general-purpose v2
Standard general-purpose v1
Write operations
Append Block From URL (source account2) Premium block blob
Standard general-purpose v2
Standard general-purpose v1
Read operations

1The destination account is charged for one transaction to initiate the write.
2The source account incurs one transaction for each read request to the source.