简体   繁体   中英

Error "The specified resource does not exist" when trying to copy blob from storage to another

I'm trying to move a blob file from a container to another that is in another storage.

public void MoveFile(StorageConfig sourceConfig, StorageConfig destinationConfig, string sourceFilename, string destinationFilename)
    {
        var sContainer = GetBlobContainerReference(sourceConfig.ConnectionString, sourceConfig.ContainerName);
        var dContainer = GetBlobContainerReference(destinationConfig.ConnectionString, destinationConfig.ContainerName);

        var sBlob = sContainer.GetBlockBlobReference(sourceFilename);
        var dBlob = dContainer.GetBlockBlobReference(destinationFilename);

        dBlob.StartCopy(sBlob);

        sBlob.Delete(DeleteSnapshotsOption.IncludeSnapshots);
    }

I have distinct credentials for Source and Destination containers.

When I run this code, the error occurs on the line dBlob.StartCopy(sBlob);

And the error "The specified resource does not exist" is thrown.

The sBlob.Delete() works with no error, so it is reaching the source blob file.

I watch these variables:

sBlob.Exists() -> true
dBlob.Exists() -> false
sContainer.Exists() -> true
dContainer.Exists() -> true

So it can connect in both containers.

Did I need to create the destination blob first? I think not based on some codes I found in the inte.net.

For copying blob from one account to another, the source blob must be publicly accessible. This restriction does not apply when a blob is copied within same storage account.

The reason you are getting this error is most likely because your source blob is in a private container.

To fix this issue, create a SAS URL for the source blob with at least read permission and use that URL for copying blob.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM