Put Block From URL
Put Block From URL operation creates a new block to be committed as part of a blob where the contents are read from a URL. This API is available starting in version
Put Block From URL request may be constructed as follows. HTTPS is recommended. Replace myaccount with the name of your storage account:
|PUT Method Request URI||HTTP Version|
Emulated Storage Service URI
When making a request against the emulated storage service, specify the emulator hostname and Blob service port as
127.0.0.1:10000, followed by the emulated storage account name:
|PUT Method Request URI||HTTP Version|
For more information, see Using the Azure Storage Emulator for Development and Testing.
||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
Note that the Base64 string must be URL-encoded.
The following table describes required and optional request headers.
||Required. Specifies the authentication scheme, account name, and signature. See Authentication for the Azure Storage Services for more information.|
||Required. Specifies the Coordinated Universal Time (UTC) for the request. For more information, see Authentication for the Azure Storage Services.|
||Required for all authenticated requests. Specifies the version of the operation to use for this request. For more information, see Versioning for the Azure Storage Services. For Put Block From URL, the version has to be 2018-03-28 or newer.|
||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 the status code 400 (Bad Request).|
||Required. Specifies the URL of the source blob. The value may be a URL of up to 2 KB 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 authenticated via a shared access signature. If the source blob is public, no authentication is required to perform the operation. Here are some examples of source object URLs:
||Optional. Uploads only the bytes of the blob in the source URL in the specified range. If this is not specified, the entire source blob contents are uploaded as a single block. See Specifying the Range Header for Blob Service Operations for more information.|
||Optional. A MD5 hash of the block content from the URI. This hash is used to verify the integrity of the block during transport of the data from the URI. When this header is specified, 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 is not stored with the blob.
If the two hashes do not match, the operation will fail with error code 400 (Bad Request).
||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.|
||Optional. Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. Using this header is highly recommended for correlating client-side activities with requests received by the server. For more information, see About Storage Analytics Logging and Azure Logging: Using Logs to Track Storage Requests.|
No request body.
Request Syntax: PUT https://myaccount.blob.core.windows.net/mycontainer/myblob?comp=block&blockid=AAAAAA%3D%3D HTTP/1.1 Request Headers: x-ms-version: 2018-03-28 x-ms-date: Sat, 31 Mar 2018 14:37:35 GMT Authorization: SharedKey myaccount:J4ma1VuFnlJ7yfk/Gu1GxzbfdJloYmBPWlfhZ/xn7GI= Content-Length: 0 x-ms-copy-source: https://myaccount.blob.core.windows.net/mycontainer/myblob x-ms-source-range: bytes=0-499
The response includes an HTTP status code and a set of response headers.
A successful operation returns status code 201 (Created).
For information about status codes, see Status and Error Codes.
The response for this operation includes the following headers. The response may also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.
||This header is returned so that the client can check for message content integrity. The value of this header is computed by the Blob service; it is not necessarily the same value specified in the request headers.|
||This header uniquely identifies the request that was made and can be used for troubleshooting the request. For more information, see Troubleshooting API Operations.|
||Indicates the version of the Blob service used to execute the request.|
||A UTC date/time value generated by the service that indicates the time at which the response was initiated.|
||Version 2015-12-11 or newer. The value of this header is set to
Response Status: HTTP/1.1 201 Created Response Headers: Transfer-Encoding: chunked Content-MD5: BN3lsXf+t19nMGs+vYakPA== Date: Sat, 31 Mar 2018 23:47:09 GMT Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
This operation can be called by the account owner and by anyone with a Shared Access Signature that has permission to write to this blob or its container.
Put Block From URL uploads a block for future inclusion in a block blob. A block blob can include a maximum of 50,000 blocks. Each block can be a different size, up to a maximum of 100 MB. The maximum size of a block blob is therefore slightly more than 4.75 TB (100 MB X 50,000 blocks).
A blob can have a maximum of 100,000 uncommitted blocks at any given time. The set of uncommitted blocks cannot exceed 9.52 TB in total size. If this maximum is exceeded, the service returns status code 409 (RequestEntityTooLargeBlockCountExceedsLimit).
After you have uploaded a set of blocks, you can create or update the blob on the server from this set by calling the Put Block List operation. Each block in the set is identified by a block ID that is unique within that blob. Block IDs are scoped to a particular blob, so different blobs can have blocks with same IDs.
If you call
Put Block From URL on a blob that does not yet exist, a new block blob is created with a content length of 0. This blob is enumerated by the
List Blobs operation if the
include=uncommittedblobs option is specified. The block or blocks that you uploaded are not committed until you call
Put Block List on the new blob. A blob created this way is maintained on the server for a week; if you have not added more blocks or committed blocks to the blob within that time period, then the blob is garbage collected.
A block that has been successfully uploaded with the
Put Block From URL operation does not become part of a blob until it is committed with
Put Block List. Before
Put Block List is called to commit the new or updated blob, any calls to Get Blob return the blob contents without the inclusion of the uncommitted block.
If you upload a block that has the same block ID as another block that has not yet been committed, the last uploaded block with that ID will be committed on the next successful
Put Block List operation.
Put Block List is called, all uncommitted blocks specified in the block list are committed as part of the new blob. Any uncommitted blocks that were not specified in the block list for the blob will be garbage collected and removed from the Blob service. Any uncommitted blocks will also be garbage collected if there are no successful calls to
Put Block From URL or
Put Block List on the same blob within a week following the last successful
Put Block From URL operation. If Put Blob is called on the blob, any uncommitted blocks will be garbage collected.
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 does not specify a lease ID, or specifies an invalid lease ID, the Blob service returns status code 412 (Precondition Failed). If the client specifies a lease ID but the blob does not have an active lease, the Blob service also returns status code 412 (Precondition Failed).
For a given blob, all block IDs must be the same length. If a block is uploaded with a block ID of a different length than the block IDs for any existing uncommitted blocks, the service returns error response code 400 (Bad Request).
Put Block From URL does not update the last modified time of an existing blob.
Put Block From URL on a page blob returns an error.
Put Block From URL on an archived blob will return an error and on
Cool blob does not change the blob tier.