Copy Blob From URL (REST API) - Azure Storage (2023)

  • Article
  • 11 minutes to read

The Copy Blob From URL operation copies a blob to a destination within the storage account synchronously for source blob sizes up to 256 mebibytes (MiB). This API is available starting in version 2018-03-28.

The source for a Copy Blob From URL operation can be any committed block blob in any Azure storage account that's either public or authorized with a shared access signature.

Request

You can construct the Copy Blob From URL request as follows. We recommend HTTPS. Replace myaccount with the name of your storage account, mycontainer with the name of your container, and myblob with the name of your destination blob.

PUT method request URIHTTP version
https://myaccount.blob.core.windows.net/mycontainer/myblobHTTP/1.1

URI for the emulated storage service

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

PUT method request URIHTTP version
http://127.0.0.1:10000/devstoreaccount1/mycontainer/myblobHTTP/1.1

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

URI parameters

You can specify the following additional parameters on the request URI:

(Video) Azure Blob Storage -Access Blob From Azure Storage Account Using Postman Tool

ParameterDescription
timeoutOptional. The timeout parameter is expressed in seconds. For more information, see Set timeouts for Blob Storage operations.

Request headers

The following table describes required and optional request headers:

Request headerDescription
AuthorizationRequired. Specifies the authorization scheme, account name, and signature. For more information, see Authorize requests to Azure Storage.
Date or x-ms-dateRequired. Specifies the Coordinated Universal Time (UTC) for the request. For more information, see Authorize requests to Azure Storage.
x-ms-versionRequired for all authorized requests. For more information, see Versioning for the Azure Storage services.
x-ms-meta-name:valueOptional. Specifies a user-defined name/value pair associated with the blob. 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.

Beginning with version 2009-09-19, metadata names must adhere to the naming rules for C# identifiers. For more information, see Naming and referencing containers, blobs, and metadata.

x-ms-encryption-scopeOptional. Indicates the encryption scope for encrypting the request contents. This header is supported in version 2020-12-06 and later.
x-ms-tagsOptional. Sets query-string-encoded tags on the blob. Tags are not copied from the copy source. For more information, see Remarks. Supported in version 2019-12-12 and later.
x-ms-copy-source-tag-optionOptional. Possible values are REPLACE and COPY (case-sensitive). The default value is REPLACE.

If COPY is specified, the tags from the source blob will be copied to the destination blob. The source blob must be private, and the request must have permission to the Get Blob Tags operation on the source blob and the Set Blob Tags operation on the destination blob. This incurs an extra call to the Get Blob Tags operation on the source account.

REPLACE will set tags that the x-ms-tags header specifies on the destination blob. If x-ms-tags specifies REPLACE and no tags, then no tags will be set on the destination blob. Specifying COPY and x-ms-tags will result in a 409 (Conflict) error.

Supported in version 2021-04-10 and later.

x-ms-source-if-modified-sinceOptional. A DateTime value. Specify this conditional header to copy the blob only if the source blob has been modified since the specified date/time. If the source blob has not been modified, Blob Storage returns status code 412 (Precondition Failed). You can't specify this header if the source is an Azure file.
x-ms-source-if-unmodified-sinceOptional. A DateTime value. Specify this conditional header to copy the blob only if the source blob has not been modified since the specified date/time. If the source blob has been modified, Blob Storage returns status code 412 (Precondition Failed). You can't specify this header if the source is an Azure file.
x-ms-source-if-matchOptional. An ETag value. Specify this conditional header to copy the source blob only if its ETag value matches the specified value. If the values don't match, Blob Storage returns status code 412 (Precondition Failed). You can't specify this header if the source is an Azure file.
x-ms-source-if-none-matchOptional. An ETag value. Specify this conditional header to copy the blob only if its ETag value doesn't match the specified value. If the values are identical, Blob Storage returns status code 412 (Precondition Failed). You can't specify this header if the source is an Azure file.
If-Modified-SinceOptional. A DateTime value. 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, Blob Storage returns status code 412 (Precondition Failed).
If-Unmodified-SinceOptional. A DateTime value. 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, Blob Storage returns status code 412 (Precondition Failed).
If-MatchOptional. An ETag value. 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 values don't match, Blob Storage returns status code 412 (Precondition Failed).
If-None-MatchOptional. 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 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-copy-source:nameRequired. Specifies the URL of the source blob. The value can 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 256 MiB, the request fails with a 409 (Conflict) error. The blob type of the source blob has to be block blob. 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.
Only the scheme bearer is supported for Azure Active Directory.
This header is supported in version 2020-10-02 and later.
x-ms-requires-sync:trueRequired. Indicates that this is a synchronous Copy Blob From URL operation instead of an asynchronous Copy Blob operation.
x-ms-source-content-md5Optional. Specifies 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.

The MD5 hash is not stored with the blob.

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

x-ms-lease-id:<ID>Required if the destination blob has an active lease. The lease ID specified for this header must match the lease ID of the destination blob. If the request doesn't include the lease ID or it isn't valid, the operation fails with status code 412 (Precondition Failed).

If this header is specified and the destination blob doesn't currently have an active lease, the operation fails with status code 412 (Precondition Failed).

In version 2012-02-12 and later, this value must specify an active, infinite lease for a leased blob. A finite-duration lease ID fails with status code 412 (Precondition Failed).

x-ms-client-request-idOptional. Provides a client-generated, opaque value with a 1-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.
x-ms-access-tierOptional. Specifies the tier to be set on the target blob. This header is for page blobs on a premium account only with version 2017-04-17 and later. For a full list of supported tiers, see High-performance premium storage and managed disks for VMs. This header is supported on version 2018-11-09 and later for block blobs. Block blob tiering is supported on Blob Storage or General Purpose v2 accounts. Valid values are Hot, Cool, Cold and Archive. Please note that Cold tier is currently in preview and is supported from Version 2021-12-02 and newer. For detailed information about block blob tiering, see Hot, cool, and archive storage tiers.

Request body

None.

Response

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

Status code

A successful operation returns status code 202 (Accepted).

For information about status codes, see Status and error codes.

Response headers

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

Response headerDescription
ETagIf the copy is complete, contains the ETag value of the destination blob. If the copy isn't complete, contains the ETag value of the empty blob created at the start of the copy.

The ETag value is in quotation marks.

Last-ModifiedReturns the date/time that the copy operation to the destination blob finished.
x-ms-request-idUniquely identifies the request that was made. You can use it to troubleshoot the request. For more information, see Troubleshoot API operations.
x-ms-versionIndicates the version of Blob Storage that's used to execute the request.
DateA UTC date/time value that indicates the time at which the service sent the response.
x-ms-copy-id: <id>String identifier for this copy operation.
x-ms-copy-status: <success>Indicates the state of the copy operation. A value of success means that the operation finished successfully.
x-ms-client-request-idCan be used to troubleshoot requests and corresponding responses. The value of this header is equal to the value of the x-ms-client-request-id header, if it's present in the request and the value is at most 1,024 visible ASCII characters. If the x-ms-client-request-id header is not present in the request, this header won't be present in the response.
x-ms-request-server-encrypted: true/falseSet to true if the contents of the request are successfully encrypted through the specified algorithm. Otherwise, the value is false.
x-ms-encryption-scopeReturned if the request used an encryption scope, so the client can ensure that the contents of the request are successfully encrypted through the encryption scope.

Response body

None.

Sample response

The following is a sample response for a request to copy a blob:

(Video) Azure Storage Account using REST APIs in POSTMAN

Response Status: HTTP/1.1 202 Accepted Response Headers: Last-Modified: <date> ETag: "0x8CEB669D794AFE2" Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-request-id: cc6b209a-b593-4be1-a38a-dde7c106f402 x-ms-version: 2018-03-28 x-ms-copy-id: 1f812371-a41d-49e6-b123-f4b542e851c5 x-ms-copy-status: success Date: <date> 

Authorization

This operation can be called by the account owner and by anyone with a shared access signature who has permission to write to this blob or its container.

Access to the source blob or file is authorized separately, as described in the details for the request header x-ms-copy-source.

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.

Remarks

The source and destination blob for a Copy Blob From URL operation must be a block blob.

In version 2020-10-02 and later, Azure Active Directory authorization is supported for the source of the copy operation.

The Copy Blob From URL operation always copies the entire source blob. Copying a range of bytes or set of blocks is not supported.

You can copy a source blob to a destination blob that has a different name. The destination blob can be an existing block blob, or it can be a new blob that the copy operation creates.

When you're copying from a block blob, all committed blocks and their block IDs are copied. Uncommitted blocks are not copied. At the end of the copy operation, the destination blob will have the same committed block count as the source.

(Video) Copy Azure Blobs From One Storage Account to Another Using AzCopy

The ETag value for a block blob changes when the Copy Blob From URL operation starts and when the operation finishes.

Copying blob properties and metadata

When a block 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

    (Video) Using Azure Blob Storage Example

  • Content-Disposition

The source blob's committed block list is also copied to the destination 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 matches the value of that header for the source blob.

If the x-ms-tags header provides tags for the destination blob, they must be query-string encoded. Tag keys and values must conform to the naming and length requirements specified in the Set Blob Tags operation.

The x-ms-tags header can contain up to 2 kilobits of tags. If you need more tags, use the Set Blob Tags operation.

If the x-ms-tags header doesn't provide tags, then tags aren't copied from the source blob.

Copying a leased blob

The Copy Blob From URL operation only reads from the source blob, so the lease state of the source blob doesn't matter.

Billing

The destination account of a Copy Blob From URL operation is charged for one transaction to start the operation. The destination account also incurs one transaction for each request to the source of the copy operation.

(Video) How to Read the data from Rest API and write to Blob Storage in ADF By using REST Connector in ADF

The source account also incurs transaction costs. In addition, if the source and destination accounts reside in different regions (for example, US North and US South), bandwidth that you use to transfer the request is charged to the source storage account as egress. Egress between accounts within the same region is free.

When you copy a source blob to a destination blob that has a different name within the same account, you use additional storage resources for the new blob. The copy operation then results in a charge against the storage account's capacity usage for those additional resources.

See also

Authorize requests to Azure Storage
Status and error codes
Blob Storage error codes
Understanding how snapshots accrue charges

FAQs

How do I access Azure blob storage from URL? ›

You can also retrieve a blob using an HTTPS/HTTP request. One way to find the URL of the blob is by using the Azure portal by going to Home > Storage Account > Container > Blob > Properties. However, probably the easiest way is to find the blob in the Storage Explorer, right-click, then select 'Copy URL'.

How do I copy Azure blob storage? ›

Copy a source file in the Azure File service to a destination blob. The destination blob can be an existing block blob, or can be a new block blob created by the copy operation. Copying from files to page blobs or append blobs is not supported. Copy a snapshot over its base blob.

How do I check my blob storage capacity? ›

Calculate the size/capacity of storage account and it services (...
  1. Sign in to the Azure portal.
  2. Select Monitor from the left-hand pane in the Azure portal, and.
  3. Under the Insights section, select Storage Accounts (preview).
Dec 12, 2019

How do I upload files to Azure blob storage using REST API? ›

To get your account key, in the Azure portal, go to your storage account. Go to Settings > Access keys, select a key, and paste it into the AzCopy command. If the specified destination container does not exist, AzCopy creates it and uploads the file into it.

What URL format can blobs can be accessed from? ›

Users or client applications can access objects in Blob Storage via HTTP/HTTPS, from anywhere in the world.

How do I extract a blob link? ›

Right-click on the webpage and click “Inspect” in the menu. When the DevTools panel opens, click on the three vertical dots in the top-right corner and select the “double window” icon (Undock into a separate window). Press “Ctrl + F” on Windows or “Cmd + F” on Mac to find the blob URL.

How do I copy files to blob storage? ›

In this article, I am going to explain the following:
  1. Generate a shared access signature to connect to azure blob storage.
  2. Create a container on the Azure blob storage.
  3. Upload files on the container.
  4. Upload the entire directory on the container.
  5. Upload specific files on the container.
Feb 19, 2020

What is the difference between AzCopy and AZ storage blob copy? ›

The difference between both is AzCopy is a command-line utility designed for copying data to/from Microsoft Azure Blob, File, and Table storage, using simple commands designed for optimal performance.

Can you query blob storage? ›

The Query Blob Contents operation applies a simple Structured Query Language (SQL) statement on a blob's contents and returns only the queried subset of the data. You can also call Query Blob Contents to query the contents of a version or snapshot.

What is the max size of blob? ›

A BLOB (binary large object) is a varying-length binary string that can be up to 2,147,483,647 characters long.

What is the limit of Azure blob storage? ›

Scale targets for Blob storage
ResourceTarget
Maximum size of single blob containerSame as maximum storage account capacity
Maximum number of blocks in a block blob or append blob50,000 blocks
Maximum size of a block in a block blob4000 MiB
Maximum size of a block blob50,000 X 4000 MiB (approximately 190.7 TiB)
7 more rows
Jan 11, 2023

How do I increase Azure blob storage size? ›

Azure File storage: Increase the size of available storage
  1. Navigate to File Shares.
  2. Click on the ellipsis on the file share and select "Edit quota"
  3. Enter the new file store size.
Apr 9, 2020

How do I use a SAS URL to upload files to Azure blob storage? ›

If you'd rather use a SAS token to authorize access to blob data, then you can append that token to the resource URL in each AzCopy command. For example: 'https://<storage-account-name>.blob.core.windows.net/<container-name><SAS-token>' .

How do I download from Azure blob storage using API? ›

Download Files from Azure Blob Storage with Blazor WebAssembly and ASP.NET Web API
  1. Create the Azure Blob Storage. Create the Azure Blob Storage to store the files. ...
  2. Create an ASP.NET Core Web API project and connect it to the Azure Blob Storage. ...
  3. Implement the endpoints in the ASP.NET Core Web API project.
Aug 4, 2022

How do I transfer data to Azure blob storage? ›

Next steps
  1. Get an introduction to Azure Storage Explorer.
  2. Read an overview of AzCopy.
  3. Quickstart: Upload, download, and list blobs with PowerShell.
  4. Quickstart: Create, download, and list blobs with Azure CLI.
  5. Learn about: ...
  6. Learn what is Azure Data Factory.
  7. Use the REST APIs to transfer data.
Nov 21, 2022

How do I find the URL of a blob object? ›

You can get a container or blob URL by using the url property of the client object: ContainerClient. url.

Is blob URL safe? ›

Blob URLs are considered unsafe #947.

How do I convert a blob URL to a normal URL? ›

A URL that was created from a JavaScript Blob can not be converted to a "normal" URL. A blob: URL does not refer to data the exists on the server, it refers to data that your browser currently has in memory, for the current page.

What is blob in front of URL? ›

The Blob object represents a blob, which is a file-like object of immutable, raw data; they can be read as text or binary data, or converted into a ReadableStream so its methods can be used for processing the data. Blobs can represent data that isn't necessarily in a JavaScript-native format.

What is the endpoint URL for Blob service? ›

The default endpoint for Blob storage is https://<mystorageaccount>.blob.core.windows.net. If you map a custom domain and subdomain such as www.contoso.com to the blob endpoint for your storage account, then your users can also access blob data in your storage account using that domain.

What is Blob HTTP URL? ›

The Blob object represents a blob, which is a file-like object of immutable, raw data; they can be read as text or binary data, or converted into a ReadableStream so its methods can be used for processing the data. Blobs can represent data that isn't necessarily in a JavaScript-native format.

How do I find the URL of a Blob object? ›

You can get a container or blob URL by using the url property of the client object: ContainerClient. url.

How do you get the path for Blob storage Azure? ›

Set Up a Microsoft Azure Blob Storage File Location
  1. Hover over your name and click Setup.
  2. In the Data Management section, click File Locations.
  3. Click Create.
  4. Complete the information in the Properties section. ...
  5. For the location type, select Azure Blob Storage.
  6. Complete the location information. ...
  7. Save the file location.

How do I send blob URL to server? ›

Syntax: fetch( url, // API endpoint { method:"", // HTTP Method (GET, POST, PUT, DELETE) body: {}, // Data to be sent }). then(response => { // handle the response }) . catch(e => { // handle the error });

What is an example of blob as URL? ›

A blob URI looks like blob:http://example.com/550e8400-e29b-41d4-a716-446655440000 , with the end of the URI being a universally unique identifier.

What are the three types of blobs? ›

The storage service offers three types of blobs, block blobs, append blobs, and page blobs.

Videos

1. Upload File to Azure Blob Storage using Azure REST API with PowerShell
(Cloud Quick Labs)
2. #25. How to pull data from RestApi and write it into Blob Storage|JSON| AzureDataFactory Tutorial |
(GeekCoders)
3. Web Api+Azure Storage Account Download File|Download File from Azure storage
(AzureTeach•Net)
4. How to use Azure Blob Storage with .Net 6 | Azure Blob Storage Tutorial
(Israel Quiroz)
5. 2 Read data from an API, Parse JSON and write to BLOB storage using Azure Data Factory i.e. ADF.
(QuickTechTips@Siba)
6. 32. Copy data from REST API which sends response in Pages using Azure data factory
(WafaStudies)
Top Articles
Latest Posts
Article information

Author: Reed Wilderman

Last Updated: 09/06/2023

Views: 6599

Rating: 4.1 / 5 (72 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Reed Wilderman

Birthday: 1992-06-14

Address: 998 Estell Village, Lake Oscarberg, SD 48713-6877

Phone: +21813267449721

Job: Technology Engineer

Hobby: Swimming, Do it yourself, Beekeeping, Lapidary, Cosplaying, Hiking, Graffiti

Introduction: My name is Reed Wilderman, I am a faithful, bright, lucky, adventurous, lively, rich, vast person who loves writing and wants to share my knowledge and understanding with you.