Can't copy blob with Java API

Rob N 46 Reputation points

I'm trying to get started with the Java API.

val blobServiceClient = BlobServiceClientBuilder().connectionString(connectStr).buildClient()
val containerClient = blobServiceClient.getBlobContainerClient("my-stuff")
val blobClient = containerClient.getBlobClient("Test1.txt")
val newBlobClient = containerClient.getBlobClient("Test2.txt")

I get an error saying "The specified resource does not exist":

Exception in thread "main" Status code 404, "<?xml version="1.0" encoding="utf-8"?><Error><Code>CannotVerifyCopySource</Code><Message>The specified resource does not exist.

But it does exist. I can download it; this works:

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,269 questions
0 comments No comments
{count} votes

Accepted answer
  1. deherman-MSFT 31,996 Reputation points Microsoft Employee

    @Rob N
    Please try attaching a SAS token with appropriate permissions to the copy source url. There is a recent GitHub thread where a user faced the same issue. Here is the code that worked for them:

    String sasToken = sourceBlobClient.generateSasToken();  
    copyBlobClient.copyFromUrl(sourceBlobClient.getBlobUrl() + "?" + sasToken);  

    Hope this helps. Let us know if you need further assistance or have further issues.


    Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

0 additional answers

Sort by: Most helpful