Put Blob From URL
The Put Blob From URL
operation creates a new block blob where the contents of the blob are read from a specified URL. This API is available as of version 2020-04-08.
Partial updates aren't supported with Put Blob From URL
. The contents of an existing blob are overwritten with the contents of the new blob. To perform partial updates to a block blob’s contents by using a source URL, use the Put Block From URL
API in conjunction with Put Block List
.
The size of the source blob can be up to a maximum length of 5,000 mebibytes (MiB).
Request
You can construct the Put Blob From URL
as follows. We recommend that you use HTTPS. Replace myaccount with the name of your storage account:
PUT method request URI | HTTP version |
---|---|
https://myaccount.blob.core.windows.net/mycontainer/myblob |
HTTP/1.1 |
Emulated storage service request
When you're making a request against the emulated storage service, specify the emulator host name and Blob service 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 |
HTTP/1.1 |
The storage emulator supports blob sizes of up to 2 gibibytes (GiB) only.
For more information, see Use the Azurite emulator for local Azure Storage development.
URI parameters
The following additional parameters may be specified on the request URI:
Parameter | Description |
---|---|
timeout |
Optional. The timeout parameter is expressed in seconds. For more information, see Set time-outs for Blob service operations. |
Request headers
The required and optional request headers are described in the following table:
Request header | Description |
---|---|
Authorization |
Required. Specifies the authorization scheme, account name, and signature. For more information, see Authorize requests to Azure Storage. |
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 0. When the length isn't 0, the operation fails with the status code 400 (Bad Request). |
x-ms-copy-source:name |
Required. Specifies the URL of the source blob. The value may be a URL of up to 2 kibibytes (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 be authorized via a shared access signature. If the source blob is public, no authorization is required to perform the operation. If the size of the source blob is greater than 5000 MiB, or if the source does not return a valid Content-Length value, the request fails with the status code 409 (Conflict). 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 the copy source. For more information, see Authorize requests to Azure Storage. Note: Only a bearer scheme is supported for Microsoft Entra. Note: If your source object is publicly accessible or your source object is in a storage account and you are using a SAS token that is being passed in x-ms-copy-source:name , this header is not needed.This header is supported in versions 2020-10-02 and later. |
x-ms-blob-type: BlockBlob |
Required. Specifies the type of blob to create, which must be BlockBlob . If the blob type isn't BlockBlob , the operation fails with status code 400 (Bad Request). |
Content-Type |
Optional. The MIME content type of the blob. The default type is application/octet-stream . |
Content-Encoding |
Optional. Specifies which content encodings have been applied to the blob. This value is returned to the client when the Get Blob operation is performed on the blob resource. When this value is returned, the client can use it to decode the blob content. |
Content-Language |
Optional. Specifies the natural languages used by this resource. |
Cache-Control |
Optional. Blob Storage stores this value but doesn't use or modify it. |
x-ms-source-content-md5 |
Optional. An MD5 hash of the blob content from the URI. This hash is used to verify the integrity of the blob 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. If this header is omitted, Blob Storage generates an MD5 hash. If the two hashes don't match, the operation fails with error code 400 (Bad Request). |
x-ms-content-crc64 |
Optional. A CRC64 hash of the blob content. This hash is used to verify the integrity of the blob during transport. When this header is specified, the storage service checks the hash that has arrived against the one that was sent. If the two hashes don't match, the operation fails with error code 400 (Bad Request). This header is supported in version 02-02-2019 and later. If both Content-MD5 and x-ms-content-crc64 headers are present, the request fails with a 400 (Bad Request). |
x-ms-blob-content-type |
Optional. Sets the blob's content type. |
x-ms-blob-content-encoding |
Optional. Sets the blob's content encoding. |
x-ms-blob-content-language |
Optional. Sets the blob's content language. |
x-ms-blob-content-md5 |
Optional. Sets the blob's MD5 hash. |
x-ms-blob-cache-control |
Optional. Sets the blob's cache control. |
x-ms-meta-name:value |
Optional. The name-value pairs that are associated with the blob as metadata. Note: As of version 2009-09-19, metadata names must adhere to the naming rules for C# identifiers. |
x-ms-encryption-scope |
Optional. The encryption scope to use to encrypt the request contents. This header is supported in version 2019-02-02 and later. |
x-ms-tags |
Optional. Sets the specified query-string-encoded tags on the blob. For more information, go to the Remarks section. Supported in version 2019-12-12 and later. |
x-ms-copy-source-tag-option |
Optional. Possible values are REPLACE or COPY (case-sensitive). The default value is REPLACE. If COPY is specified, the tags from the source blob are copied to the destination blob. The source blob must be private, and the request must have permission to Get Blob Tags on the source blob and Set Blob Tags on the destination blob. This incurs an extra call to the Get Blob Tags operation on the source account. REPLACE sets tags that are specified by the x-ms-tags header on the destination blob. If REPLACE is used and no tags are specified by x-ms-tags , no tags are set on the destination blob. Specifying COPY and x-ms-tags results in a 409 (Conflict).Supported in version 2021-04-10 and later. |
x-ms-copy-source-blob-properties |
Optional. Specifies the copy source blob properties behavior. If set to True , the properties of the source blob will be copied to the new blob. The default value is True . |
x-ms-source-if-modified-since |
Optional. A DateTime value. Specify this conditional header to put the blob only if the source blob has been modified since the specified date/time. If the source blob hasn't been modified, Blob Storage returns status code 412 (Precondition Failed). This header can't be specified if the source is an Azure Files share. |
x-ms-source-if-unmodified-since |
Optional. A DateTime value. Specify this conditional header to put the blob only if the source blob hasn't been modified since the specified date/time. If the source blob has been modified, Blob Storage returns status code 412 (Precondition Failed). This header can't be specified if the source is an Azure Files share. |
x-ms-source-if-match |
Optional. An ETag value. Specify this conditional header to put the source blob only if its ETag matches the specified value. If the ETag values don't match, Blob Storage returns status code 412 (Precondition Failed). This header can't be specified if the source is an Azure Files share. |
x-ms-source-if-none-match |
Optional. An ETag value. Specify this conditional header to put the blob only if its ETag doesn't match the specified value. If the values are identical, Blob Storage returns status code 412 (Precondition Failed). This header can't be specified if the source is an Azure Files share. |
If-Modified-Since |
Optional. A DateTime value. Specify this conditional header to put the blob only if the destination blob has been modified since the specified date/time. If the destination blob hasn't been modified, Blob Storage returns status code 412 (Precondition Failed). |
If-Unmodified-Since |
Optional. A DateTime value. Specify this conditional header to put the blob only if the destination blob hasn't been modified since the specified date/time. If the destination blob has been modified, Blob Storage returns status code 412 (Precondition Failed). |
If-Match |
Optional. An ETag value. Specify an ETag value for this conditional header to put the blob only if the specified ETag value matches the ETag value for an existing destination blob. If the ETag for the destination blob doesn't match the ETag specified for If-Match , Blob Storage returns status code 412 (Precondition Failed). |
If-None-Match |
Optional. An ETag value, or the wildcard character (*). Specify an ETag value for this conditional header to put the blob only if the specified ETag value doesn't match the ETag value for the destination blob. Specify the wildcard character (*) to perform the operation only if the destination blob doesn't exist. If the specified condition isn't met, Blob Storage returns status code 412 (Precondition Failed). |
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-blob-content-disposition |
Optional. Sets the blob’s Content-Disposition header. Available for version 2013-08-15 and later.The Content-Disposition response header field conveys additional information about how to process the response payload, and it can be used to attach additional metadata. For example, if the header is set to attachment , it indicates that the user-agent shouldn't display the response. Instead, it should display a Save As dialog with a file name other than the specified blob name.The response from the Get Blob and Get Blob Properties operations includes the content-disposition header. |
Origin |
Optional. Specifies the origin from which the request is issued. The presence of this header results in cross-origin resource sharing (CORS) headers on the response. For more information, see CORS support for the Azure Storage services. |
x-ms-client-request-id |
Optional. Provides a client-generated, opaque value with a 1-kibibyte (KiB) character limit that's recorded in the analytics logs when storage analytics logging is enabled. We highly recommend that you use this header to correlate client-side activities with requests that the server receives. |
x-ms-access-tier |
Optional. Indicates the tier to be set on the blob. Valid values for block blob tiers are Hot , Cool , Cold , and Archive . Note: Cold tier is supported for version 2021-12-02 and later. Hot , Cool , and Archive are supported for version 2018-11-09 and later. For more information about block blob tiering, see Hot, cool, and archive storage tiers. |
x-ms-expiry-option |
Optional. Version 2023-08-03 and later. Specifies the expiration date option for the request. For more information, see ExpiryOption. This header is valid for accounts with hierarchical namespace enabled. |
x-ms-expiry-time |
Optional. Version 2023-08-03 and later. Specifies the time when the blob is set to expire. The format for expiration date varies according to x-ms-expiry-option . For more information, see ExpiryOption. This header is valid for accounts with hierarchical namespace enabled. |
This operation also supports the use of conditional headers to write the blob only if a certain condition is met. For more information, see Specify conditional headers for Blob Storage operations.
Request headers (customer-provided encryption keys)
The following headers may be specified 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
None.
Sample request
The following example shows a request to create a block blob:
Request Syntax:
PUT https://myaccount.blob.core.windows.net/mycontainer/myblockblob HTTP/1.1
Request Headers:
x-ms-version: 2020-04-08
x-ms-date: <date>
Content-Type: text/plain; charset=UTF-8
x-ms-blob-content-disposition: attachment; filename="fname.ext"
x-ms-blob-type: BlockBlob
x-ms-meta-m1: v1
x-ms-meta-m2: v2
x-ms-copy-source: https://myaccount.blob.core.windows.net/mycontainer/myblob
x-ms-expiry-option: RelativeToNow
x-ms-expiry-time: 30000
Authorization: SharedKey myaccount:YhuFJjN4fAR8/AmBrqBz7MG2uFinQ4rkh4dscbj598g=
Content-Length: 0
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 more 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 that the client can use to perform conditional PUT operations by using the If-Match request header. The ETag value is enclosed in quotation marks. |
Last-Modified |
The date/time when the blob was last modified. The date format follows RFC 1123. For more information, see Represent 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 |
Returned for a block blob so that the client can check the integrity of message content. The Content-MD5 returned value is computed by Blob Storage. This header is returned even when the request doesn't include Content-MD5 or x-ms-blob-content-md5 headers. |
x-ms-content-crc64 |
Returned for a block blob so that the client can check the integrity of message content. The x-ms-content-crc64 returned value is computed by Blob Storage. This header is always returned. |
x-ms-request-id |
Uniquely identifies the request that was made, and you can use it to troubleshoot the request. For more information, see Troubleshoot API operations. |
x-ms-version |
The version of Blob Storage that was used to execute the request. |
Date |
A UTC date/time value that's generated by the service, which indicates the time when the response was initiated. |
Access-Control-Allow-Origin |
Returned if the request includes an Origin header and CORS is enabled with a matching rule. This header returns the value of the origin request header if there's a match. |
Access-Control-Expose-Headers |
Returned if the request includes an Origin header and CORS is enabled with a matching rule. Returns the list of response headers that are to be exposed to the client or issuer of the request. |
Access-Control-Allow-Credentials |
Returned if the request includes an Origin header and CORS is enabled with a matching rule that doesn't allow all origins. This header is set to true . |
x-ms-request-server-encrypted: true/false |
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 |
Returned if the request used a customer-provided key for encryption, so that the client can ensure that the contents of the request are successfully encrypted by using the provided key. |
x-ms-encryption-scope |
Returned if the request used an encryption scope, so that the client can ensure the contents of the request are successfully encrypted by using the encryption scope. |
x-ms-version-id: <DateTime> |
Returns an opaque DateTime value that uniquely identifies the blob. The value of this header indicates the version of the blob, and it may be used in subsequent requests to access the blob. |
Response body
None.
Sample response
Response Status:
HTTP/1.1 201 Created
Response Headers:
Transfer-Encoding: chunked
Content-MD5: sQqNsWTgdUEFt6mb5y4/5Q==
x-ms-content-crc64: 77uWZTolTHU
Date: <date>
ETag: "0x8CB171BA9E94B0B"
Last-Modified: <date>
Access-Control-Allow-Origin: http://contoso.com
Access-Control-Expose-Headers: Content-MD5
Access-Control-Allow-Credentials: True
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-version-id: <DateTime>
Authorization
Authorization is required when calling any data access operation in Azure Storage. You can authorize the Put Blob From URL
operation as described below.
If a request specifies tags with the x-ms-tags
request header, the caller must meet the authorization requirements of the Set Blob Tags operation.
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 Put Blob From URL
operation, and the least privileged built-in Azure RBAC role that includes this action:
- Azure RBAC action:
- Create new block blob: Microsoft.Storage/storageAccounts/blobServices/containers/blobs/add/action
- Create new or overwrite existing block blob: Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write
- Least privileged built-in role: Storage Blob Data Contributor
To learn more about assigning roles using Azure RBAC, see Assign an Azure role for access to blob data.
Remarks
The Put Blob From URL
operation is supported as of version 2020-04-08.
In version 2020-10-02 and later, Microsoft Entra authorization is supported for the source of the copy operation.
The source blob may be of any type, including a block blob, append blob, or page blob. The destination blob, however, must be a block blob.
The Put Blob From URL
operation always copies the entire source blob. Copying a range of bytes or a set of blocks isn't supported. To perform partial updates, refer to Put Block From URL. The destination blob can be an existing block blob, or it can be a new blob that's created by the operation.
When you're using a block blob as the source object, all committed blob content is copied. However, the block list isn't preserved, and uncommitted blocks aren't copied. The content of the destination blob is identical to that of the source, but the committed block list is not preserved.
Put Blob properties and metadata
When you're creating a block blob from a copy source, the standard blob properties are copied by default from the source blob. If the application metadata is specified in the request, it's stored without copying the source blob metadata. To explicitly set any HTTP content headers, you can specify the corresponding header in the request.
Content-Type
Content-Encoding
Content-Length
Cache-Control
Content-Disposition
The size of the destination blob always matches that of the source blob. The Content-Length
header must be 0 in the Put Blob From URL
request (because there's no request body), and the content length property for the destination blob is inferred from the size of the source.
Put Blob From URL custom properties
Put Blob From Url
follows the same semantics as Put Blob
for setting custom properties associated with standard HTTP headers. For more information, see Blob custom properties
Blob index tags
If tags for the destination blob are provided in the x-ms-tags
header, they must be query-string encoded. Tag keys and values must conform to the naming and length requirements as specified in Set Blob Tags
. Further, the x-ms-tags
header may contain up to 2 KiB of tags. If more tags are required, use the Set Blob Tags
operation.
If tags aren't provided in the x-ms-tags
header, they aren't copied from the source blob.
Encryption scopes and customer-provided keys
The Put Blob From URL
API supports both encryption scopes and customer-provided keys, by using the x-ms-encryption-scope
and x-ms-encryption-key
headers, respectively.
If the x-ms-copy-source
header refers to the same source blob as the destination blob in the request URI, the Put Blob From URL
operation performs a synchronous in-place rewrite of the blob. This enables rewriting a blob to use a different encryption key or encryption scope.
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 Put Blob From URL
requests based on the storage account type:
Operation | Storage account type | Billing category |
---|---|---|
Put Blob From URL (destination account1) | Premium block blob Standard general-purpose v2 Standard general-purpose v1 |
Write operations |
Put Blob 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 object.
In addition, if the source and destination accounts reside in different regions (for example, US North and US South), the bandwidth that's used to transfer the request is charged to the source storage account as egress. Egress between accounts within the same region is free.
Finally, creating a new blob with a different name within the same storage account uses additional storage resources, so the operation results in a charge against the storage account's capacity usage for those additional resources.
To learn about pricing for the specified billing categories, see Azure Blob Storage Pricing.
See also
Authorize requests to Azure Storage Status and error codes Blob service error codes Set time-outs for Blob service operations