Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

"The specified blob does not exist" when trying to copy blob between storage accounts

I’m writing a script to copy blobs from one Azure Blob Storage Container to another; potentially in a different storage account. The gist of how I’m doing that is below:

const sourceBlobClient = BlobServiceClient.fromConnectionString(sourceConnectionString);
const sourceContainer = sourceBlobClient.getContainerClient(sourceContainerName);

const targetBlobClient = BlobServiceClient.fromConnectionString(targetConnectionString);
const targetContainer = targetBlobClient.getContainerClient(targetContainerName);

const blobName = 'something';

const sourceBlobClient = sourceContainer.getBlobClient(blobName);
const targetBlobClient = targetContainer.getBlobClient(sourceBlobClient.name);

const copyResponse = await targetBlobClient.beginCopyFromURL(sourceBlobClient.url);
// Wait on copyResponse

When testing this locally and copying between two Azure containers in a Docker Azurite container with the same Storage Account, it works fine.

In reality though, the source and destination will be on different machines on different Storage Accounts. When I run the same code (replacing the connection string of the source to be a remote machine), I get an error (pasting the last part of a very long message):

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

details: {
  errorCode: 'BlobNotFound',
  connection: 'keep-alive',
  'content-type': 'application/xml',
  date: '<. . .>',
  'keep-alive': 'timeout=5',
  server: 'Azurite-Blob/3.23.0',
  'transfer-encoding': 'chunked',
  'x-ms-request-id': '<. . .>',
  message: 'The specified blob does not exist.\n' +
    'RequestId:<. . .>\n' +
    'Time:<. . .>',
  code: 'BlobNotFound'
}

The blob definately exists in the remote source (its name was pulled from a call to listBlobsFlat).

I’m unsure of the cause of this. The docs seem to suggest that copying between accounts is now possible (this text is repeated in the beginCopyFromURL docs):

In version 2012-02-12 and later, the source for a Copy Blob operation can be a committed blob in any Azure storage account.

Am I misinterpreting the docs? Is there something else going on here?

>Solution :

For copying blob across storage accounts, source blob must be publicly accessible. Please create a SAS URL for the source blob with at least “read” permission and use that URL for copying.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading