azcopy.exe - AuthenticationErrorDetail: Signature did not match

Greg Yvkoff 151 Reputation points
2021-12-08T00:01:03.61+00:00

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.

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,486 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,164 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,628 questions
0 comments No comments
{count} votes

Accepted answer
  1. deherman-MSFT 38,006 Reputation points Microsoft Employee Moderator
    2021-12-08T19:49:03.307+00:00

    @Greg Yvkoff
    You are setting New-AzStorageContext -StorageAccountName $storageAccountUrl when it should be New-AzStorageContext -StorageAccountName $storageAccountName. Please try updating this to see if it resolves your issue.

    -------------------------------

    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.

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Optimiste 0 Reputation points
    2025-05-05T01:25:28.4533333+00:00

    J'ai des difficultés de télécharger mes fiches de révisions

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.