The source blob for a copy operation may be a block blob or a page blob, or a snapshot of either. If the destination blob already exists, it must be of the same blob type as the source blob.
Copying a source blob always copies the entire blob; copying a range of bytes or a set of blocks is not supported.
A Copy Blob operation can take any of the following forms:
-
You can copy a source blob to a destination blob with a different name from that of the source blob. The destination blob can be an existing blob, or a new blob created by the copy operation.
-
You can copy a source blob to a destination blob with the same name, effectively replacing the source blob. Such a copy operation removes any uncommitted blocks and overwrites the blob's metadata.
-
You can copy a snapshot over its base blob. By promoting a snapshot to the position of the base blob, you can restore an earlier version of a blob.
-
You can copy a snapshot to a destination blob with a different name. The resulting destination blob is a writeable blob and not a snapshot.
Note |
|
When you a copy a source blob to a destination blob with a different blob name, you use additional storage resources for the new blob, so the copy operation results in a charge against the storage account’s capacity usage for those additional resources. However, if the source and destination blob are the same, no additional charge is incurred.
When you promote a snapshot to replace its base blob, the snapshot and base blob are subsequently identical. They share blocks or pages, so the copy operation does not result in an additional charge against the storage account's capacity usage. However, if you copy a snapshot to a destination blob with a different name, an additional charge is incurred for the storage resources used by the new blob that results. Two blobs with different names cannot share blocks or pages even if they are identical. |
Copying Blob Properties and Metadata
When a blob is copied, the following system properties are copied to the destination blob with the same values:
-
Content-Type
-
Content-Encoding
-
Content-Language
-
Content-Length
-
Cache-Control
-
Content-MD5
-
x-ms-blob-sequence-number (for page blobs only)
The source blob's committed block list is also copied to the destination blob, if the blob is a block blob. Any uncommitted blocks are not copied.
The destination blob is always the same size as the source blob, so the value of the Content-Length header for the destination blob will be the same as that for the source blob.
You can specify one or more new metadata values for the destination blob by specifying the x-ms-meta-name:value header on the request. If this header is not specified, the metadata associated with the source blob is copied to the destination blob.
When the source blob and destination blob are the same, Copy Blob removes any uncommitted blocks. If metadata is specified in this case, the existing metadata is overwritten with the new metadata.
Specifying Conditional Headers
You can specify conditional headers on the request to copy the blob only if a condition is met. If the specified condition is not met, the blob is not copied, and the Blob service returns status code 412 (Precondition Failed), along with additional error information that indicates whether the unmet condition was specified for the source blob or for the destination blob.
Copying a Leased Blob
If the destination blob has an active lease, you must specify a valid lease ID for the active lease in order to copy the blob.
If the source blob has an active lease, you can optionally specify the lease ID for the source blob to copy the source blob conditionally. In this case, the source blob will be copied only if the lease ID for the source blob matches that specified on the request.
Copying a blob does not affect an existing lease on the destination blob. The destination blob's lease is maintained, whether you are copying a blob to a destination blob with a different name from the source, copying the blob to a destination blob with the same name as the source, or copying a snapshot over its base blob.
Copying Snapshots
When a source blob is copied, any snapshots of the source blob are not copied to the destination. When a destination blob is overwritten with a copy, any snapshots associated with the destination blob stay intact under its name.
You can perform a copy operation to promote a snapshot blob over its base blob. In this way you can restore an earlier version of a blob. The snapshot remains, but its source is overwritten with a copy that can be both read and written.