0
votes

I'm getting the error "The specified blob does not exist" running the Start-AzStorageBlobCopy that copies a blob into another new blob in the same folder, the problem looks to be with that destination blob.

$sasKey = 'sv=2019-02-02&ss=b&srt=sco&sp=rwdlac&se=2020-06-07T20:40:57Z&st=2020-01-07T13:40:57Z&spr=https&sig=...'
$storageContext = New-AzStorageContext -StorageAccountName 'my-storage-account' -SasToken $sasKey 
$context = $context.Context
Start-AzStorageBlobCopy `
        -Context $context `
        -SrcContainer 'labo' `
        -SrcBlob 'folder/document.txt' `
        -DestContainer 'labo' `
        -DestBlob 'folder/document2.txt' `
        -Force -Verbose 
Start-AzStorageBlobCopy: The specified blob does not exist. HTTP Status Code: 404 - HTTP Error Message: The specified blob does not exist.
ErrorCode: CannotVerifyCopySource
ErrorMessage: The specified blob does not exist.
RequestId:5ba3de1b-a01e-008f-4f35-f3644c000000
Time:2020-03-05T21:32:23.8622305Z
At line:5 char:1
    + Start-AzStorageBlobCopy `
    + ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Start-AzStorageBlobCopy], StorageException
    + FullyQualifiedErrorId : StorageException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.StartAzureStorageBlobCopy
1
SAS must start with a ? $sasKey = '?sv=2019-02-02&ss=bfqt&sr..... - Achille Serdy

1 Answers

0
votes

Just find an error in your script:

$storageContext = New-AzStorageContext -StorageAccountName 'my-storage-account' -SasToken $sasKey 

# Should be $storageContext, not $context
$context = $storageContext .Context

Then, I test with the following script:

$sasKey = '?sv=2019-02-02&ss=bfqt&srt=sco&sp=rwdlacup&se=2020-03-06T10:02:26Z&st=2020-03-06T02:02:26Z&spr=https,http&sig=tj1c***************************D'
$storageContext = New-AzStorageContext -StorageAccountName 'storagetest789' -SasToken $sasKey 
$context = $storageContext.Context
Start-AzStorageBlobCopy `
        -Context $context `
        -SrcContainer 'test' `
        -SrcBlob 'hello/world.json' `
        -DestContainer 'pub' `
        -DestBlob 'hello/world.json' `
        -Force -Verbose 

Result:

enter image description here

And, by checking in the storage account, the blob is successfully copied to destination container:

enter image description here