I am trying to copy blobs from a folder in one container to folder in another container, both in the same storage account, but am hitting authentication error. I'm using latest powershell 7 on my laptop.
$rg = "<resource group>"
$subscription = "<subscription>"
$storageAccountName = "<storage account name>"
$storageAccountUrl = "https://$storageAccountName.blob.core.windows.net"
$container = "<container name>"
#############################
# Get azure token
#############################
az account set -s $subscription
$storageAccountKey = (Get-AzStorageAccountKey -ResourceGroupName $rg -Name $storageAccountName)[0].Value
$context1 = New-AzStorageContext -StorageAccountName $storageAccountUrl -StorageAccountKey $storageAccountKey
$startExpiryTime = Get-Date
$endExpiryTime = (Get-Date).AddDays(+1)
$token = New-AzStorageAccountSASToken -Service Blob,File,Table,Queue -ResourceType Service,Container,Object -Permission "racwdlup" -Context $context1 -StartTime $startExpiryTime -ExpiryTime $endExpiryTime
#############################
# Copy files from Azure
#############################
$sourceUrl = "$storageAccountUrl/$container/CM/1"
$destinationUrl = "$storageAccountUrl/$container/test"
# these display valid values
$storageAccountKey
$token
$sourceUrl
$destinationUrl
& $azCopyExe copy $sourceUrl$token $destinationUrl --recursive=true
Error:
===== RESPONSE ERROR (ServiceCode=AuthenticationFailed) =====
Description=Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:9d9a236b-901e-000d-0ec4-ebbbff000000
Time:2021-12-07T23:48:42.6295364Z, Details:
AuthenticationErrorDetail: Signature did not match. String to sign used was <storage account>
racupwdl
bfqt
sco
2021-12-07T23:46:57Z
2021-12-08T23:46:57Z
2019-07-07
Code: AuthenticationFailed
GET https://<storage account>.blob.core.windows.net/<container>?comp=list&delimiter=%2F&include=metadata&prefix=cm%2F1%2F&restype=container&se=2021-12-08t23%3A46%3A57z&sig=-REDACTED-&sp=racupwdl&srt=sco&ss=bfqt&st=2021-12-07t23%3A46%3A57z&sv=2019-07-07&timeout=901
User-Agent: [AzCopy/10.13.0 Azure-Storage/0.14 (go1.16; Windows_NT)]
X-Ms-Client-Request-Id: [d78f4e49-e463-490a-71e9-7f53587cd12d]
X-Ms-Version: [2019-12-12]
I've tried replacing variables with string text, still same error.
I've tried hard-coding the key instead of generating a new one, still same error.
I verified timestamp on my laptop is in sync with global time.