Cannot copy blob same account same container RRS feed

  • Question

  • Hi,

    I am trying to copy a blob from the same account and container but it seems that the REST API for does not work.

    Using the Java Azure Blob Storage SDK v11 like so also does not work.

    destinationBlockBlobUrl.stageBlockFromURL(blockID, sourceBlockBlobUrl.toURL(), null)

    Below is my request:

    PUT https://myaccount.blob.core.windows.net/mycontainer/mydestinationblobname
    Authorization:SharedKey myaccount:mycomputedsignature
    x-ms-date:Wed, 11 Dec 2019 07:58:06 GMT
    User-Agent: Azure-Storage/11.0.0 (JavaJRE 11.0.1; Windows10 10.0)

    Response I get is something like this:

    com.microsoft.azure.storage.blob.models.StorageErrorException: Status code 404,
    <?xml version="1.0" encoding="utf-8"?>
        <Message>The specified resource does not exist. RequestId:90152ae1-901e-0060-40dc-af5cb9000000 Time:2019-12-11T04:38:26.1481697Z  </Message>

    According to the documentation for Copy Blob, I should be able to copy blobs from the same account by just using a Shared Key.


    Beginning with version 2012-02-12, this 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. A source blob in the same storage account can be authorized via Shared Key.

    Can someone enlighten me where it gone wrong?

    P.S. If I make the container public then copy is successful.

    Wednesday, December 11, 2019 8:19 AM

All replies

  • Apologies in delay in responding here! Based on the error message 404, The specified blob/container doesn’t exist.

    You should use Fiddler to verify that you are sending the request you think you are. You can then compare the Fiddler request with the documentation.

    Does the container already exist?

    If possible can you share the code?

    You may also use Azcopy and Azure Storage Explorer in this scenario. 

    To copy files between containers, you can use AzCopy. See the following example:
    AzCopy /Source:https://xxx.blob.core.windows.net/xxx
    /Dest:https://xxx.blob.core.windows.net/xxx /SourceKey:xxx /DestKey:xxx

    AzCopy uses the Copy Blob API to copy each file in the container.

    Hope this helps! 

    Kindly let us know if the above helps or you need further assistance on this issue.

    Do click on "Mark as Answer" and Upvote on the post that helps you, this can be beneficial to other community members.

    Thursday, December 12, 2019 7:10 AM
  • Hi Sumanth,

    Thank you very much for the reply.

    The container and blob exists because:

    1. I verified it by accessing my blob storage account.

    2. The same code/request works if I set the container public.

    3. Attach a SAS to the source.

    In addition, isn't the 404 error the default error when accessing a private blob? For me, this indicates that the REST API did not consider using the SharedKey provided in the request given that the source container is the same with the destination container.

    Below is the sample code based from <https://github.com/Azure/azure-storage-java/blob/89540f018f1160ce55619c6fe7b5f5ff57d0ce10/src/test/java/com/microsoft/azure/storage/Samples.java#L513>

    SharedKeyCredentials skc = new SharedKeyCredentials("myAccountName", "myAccountKey");
        String url = String.format("%s://%s.%s", "https", "myAccountName", "blob.core.windows.net");
        ContainerURL containerURL =
            new ServiceURL(new URL(url), StorageURL.createPipeline(skc, new PipelineOptions()))
        BlockBlobURL source = containerURL.createBlockBlobURL("mySourceBlob");
        BlockBlobURL destination = containerURL.createBlockBlobURL("myDestinationBlob");
        String blockID = Base64.getEncoder().encodeToString(UUID.randomUUID().toString().getBytes());
            .stageBlockFromURL(blockID, source.toURL(), null)
                response ->
            .blockingGet();  // this does not work
        destination.syncCopyFromURL(source.toURL()).blockingGet();  // this also does not work

    • Edited by test012345 Thursday, December 12, 2019 9:02 AM additional info
    Thursday, December 12, 2019 8:52 AM
  • I would like to follow-up on this matter.
    Monday, December 16, 2019 1:13 AM
  • We need to work closure on this issue.  If you have a support plan, I request you file a support ticket, else please do let us know, we will try and help you get a one-time free technical support. In this case, could you send an email toAzCommunity[at]Microsoft[dot]com referencing this thread and subscription ID. Please mention "ATTN subm" in the subject field. Thank you for your cooperation on this matter and look forward to your reply.


    Please take a moment to "Mark as Answer" and/or "Vote as Helpful" wherever applicable. Thanks!!

    Tuesday, December 17, 2019 11:03 AM
  •  Just checking in to see if the above answer helped. If this answers your query, do click “Mark as Answer” and Up-Vote for the same, which might be beneficial to other community members reading this thread. And, if you have any further query do let us know.
    Monday, March 2, 2020 10:19 AM