Azure / azure-storage-azcopy

The new Azure Storage data transfer utility - AzCopy v10
MIT License
613 stars 222 forks source link

401 Server failed to authenticate the request Using azcopy login #2623

Open PaulNacamuli opened 7 months ago

PaulNacamuli commented 7 months ago

10.14.1 and 10.23.0 and 10.24.0 on Windows

azcopy login --tenant-id GUID azcopy file.ext https://storage.blob.core.windows.net/Folder/file.ext

This command works exactly as expected on one windows machine (W2012). On another machine in the same net (W2019) the login prompt comes up with a token. When entered, the copy command then shows scanning... and prompts for another code. When entered, there is a 401 failure:

RESPONSE Status: 401 Server failed to authenticate the request. Please refer to the information in the www-authenticate header. Content-Length: 302 Content-Type: application/xml Date: Tue, 26 Mar 2024 19:34:04 GMT Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 Www-Authenticate: Bearer authorization_uri=https://login.microsoftonline.com/GUID/oauth2/authorize resource_id=https://storage.azure.com X-Ms-Client-Request-Id: <> X-Ms-Error-Code: NoAuthenticationInformation X-Ms-Request-Id: <> X-Ms-Version: 2023-08-03

The working source machine has a 1:1 NAT that is in the permit list. The non-working source machine has a many:1 NAT that is in the permit list.

I have not found any workaround for this yet.

Aussiemon commented 6 months ago

Getting the same error as above when using the Azure File Copy v6 task in Azure DevOps, which uses 10.24.0: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-file-copy-v6?view=azure-pipelines. The error occurs in AzCopy.exe.

Failing machine:

##[command] & "AzCopy\AzCopy.exe" copy "D:\<file path>\*" "https://<storage account>/<container name>/<blob prefix>"  --log-level=INFO --recursive
INFO: Scanning...

Failed to perform Auto-login: PSContextCredentialGet-AzAccessToken: -REDACTED-;1mRun Connect-AzAccount to login.

Working machine:

##[command] & "AzCopy\AzCopy.exe" copy "D:\<file path>\*" "https://<storage account>/<container name>/<blob prefix>"  --log-level=INFO --recursive
INFO: Scanning...
INFO: Login with Powershell context succeeded
INFO: Authenticating to destination using Azure AD
INFO: Any empty folders will not be processed, because source and/or destination doesn't have full folder support

Job <job id> has started
Log file is located at: C:\Users\<username>\.azcopy\<job id>.log
pranavmalik-msft commented 6 months ago

Hey @Aussiemon , have you considered utilizing PowerShell for this task? You could streamline the process by leveraging Connect-AzAccount to log in to Azcopy .

DevTestUser123 commented 5 months ago

Hi @Aussiemon, did you get a fix? I'm also getting same error.

johnrhunt commented 4 months ago

From my experience, it seems azcopy is riddled with bugs.