Azure / azure-storage-java

Microsoft Azure Storage Library for Java
https://docs.microsoft.com/en-us/java/api/overview/azure/storage
MIT License
189 stars 165 forks source link

Synchronous copy of blobs within the same Azure storage account is not working #556

Open arti-shinde opened 3 years ago

arti-shinde commented 3 years ago

Which service(blob, file, queue, table) does this issue concern?

blob

Which version of the SDK was used?

azure-storage java sdk version 8.6.5

What problem was encountered?

Copy with sync using startCopy API is not working across or within same container within the same storage account. If I use the other API without sync, copy works fine - Here is the sample code:-

import java.net.URISyntaxException;
import com.microsoft.azure.storage.*;
import com.microsoft.azure.storage.blob.CloudBlobClient;
import com.microsoft.azure.storage.blob.CloudBlobContainer;
import com.microsoft.azure.storage.blob.CloudBlockBlob;

public class testAzure {

    public static void main(String[] args) throws URISyntaxException, StorageException {
        String accountname = "---";
        String accountkey = "--";
        String containername = "container02";
        String source_blobname = "test1.txt";
        String sink_blobname = "test2.txt";
        StorageCredentials credentials = new StorageCredentialsAccountAndKey(accountname,accountkey);
        CloudStorageAccount account = new CloudStorageAccount(credentials);
        CloudBlobClient client = account.createCloudBlobClient();

        CloudBlobContainer container = client.getContainerReference(containername);;
        CloudBlockBlob source_cbb = container.getBlockBlobReference(source_blobname);
        CloudBlockBlob sink_cbb = container.getBlockBlobReference(sink_blobname);
        //sink_cbb.startCopy(source_cbb); //This works
        sink_cbb.startCopy(source_cbb,source_cbb.getProperties().getContentMD5(),true,null,null,null,null);
    }
}       

The above is giving the following exception :


[17:25:42.976] - [STDERR] com.microsoft.azure.storage.StorageException: The specified resource does not exist.
[17:25:42.977] - [STDERR]   at com.microsoft.azure.storage.StorageException.translateException(StorageException.java:87)
[17:25:42.977] - [STDERR]   at com.microsoft.azure.storage.core.StorageRequest.materializeException(StorageRequest.java:305)
[17:25:42.977] - [STDERR]   at com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:196)
[17:25:42.978] - [STDERR]   at com.microsoft.azure.storage.blob.CloudBlob.startCopy(CloudBlob.java:791)
[17:25:42.978] - [STDERR]   at com.microsoft.azure.storage.blob.CloudBlockBlob.startCopy(CloudBlockBlob.java:302)
[17:25:42.978] - [STDERR]   at com.microsoft.azure.storage.blob.CloudBlockBlob.startCopy(CloudBlockBlob.java:252)

Have you found a mitigation/solution?

No