Reputation: 69
I'm using the startCopy API from azure-storage java sdk version 8.6.5 to copy blobs between containers within the same storage account.
String copyJobId = cloudBlockBlob.startCopy(srcBlob, srcBlob.getProperties().getContentMD5(), true,
null, null, null, null)
And I am getting 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)
If I use the other API without sync, copy works fine -
String copyJobId = cloudBlockBlob.startCopy(srcBlob); //This works
Any idea if I am missing anything here?
Thanks in advance!!!
EDITS - Adding the screenshot of exception using the test sample code by @Bowman.
Upvotes: 1
Views: 481
Reputation: 14080
Below code works fine on my side:
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 testbowman {
public static void main(String[] args) throws Exception {
String accountname = "0730bowmanwindow";
String accountkey = "xxxxxx";
String containername = "test";
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,source_cbb.getProperties().getContentMD5(),true,null,null,null,null);
System.out.println("This is a test.");
}
}
And this is my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>testbowman</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.11</maven.compiler.source>
<maven.compiler.target>1.11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
<version>8.6.5</version>
</dependency>
</dependencies>
</project>
And this is my storage configuration:
Success copy with sync:
You can check what is the different between you can me.(By the way, startCopy(CloudBlockBlob sourceBlob)
also works on my side.)
Upvotes: 1